-
-
Notifications
You must be signed in to change notification settings - Fork 906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove optional from two member variables #1550
Remove optional from two member variables #1550
Conversation
737ec27
to
8e8b5d5
Compare
8e8b5d5
to
cc71f02
Compare
The changes to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer a test-driven approach. If working_dir
cannot be none, I'd like to see what happens with bare repositories. What kind of working_dir
are they expected to have?
A bare repo should still have working_dir afaik |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for following up.
Can you try to add clearer assertions to the different repo types, bare and non-bare, that make the relationship of these different working*
directories (even more) clear?
@@ -98,6 +98,7 @@ def test_object_resolution(self): | |||
def test_with_bare_rw_repo(self, bare_rw_repo): | |||
assert bare_rw_repo.config_reader("repository").getboolean("core", "bare") | |||
assert osp.isfile(osp.join(bare_rw_repo.git_dir, "HEAD")) | |||
assert osp.isdir(bare_rw_repo.working_dir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Could you also add an assertion of the working_tree_dir
for completeness? It's easy to confuse both which is what I did apparently. The working_dir
is the CWD of the git repository, either the working_tree_dir
or the git_dir
, which I think should be an assertion for the bare and non-bare cases.
If that assertion holds, of course, I was going by the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so the docs in base.py
say that working_tree_dir can return none
@property
def working_tree_dir(self) -> Optional[PathLike]:
""":return: The working tree directory of our git repository. If this is a bare repository, None is returned."""
return self._working_tree_dir
I've added a few more assertions, please check if I understood you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also updated the python docs of the class to mention returning None
Thanks a lot for bearing with me, I was confused by the difference between And thanks for this great contribution :)! |
Neither
working_dir
norgit_dir
appear to leave__init__()
set toNone
. Let's remove theNone
initialization, and simply use them as type markers.Fixes #1549