Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Remove optional from two member variables#1550

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

Sineaggi
Copy link
Contributor

Neitherworking_dir norgit_dir appear to leave__init__() set toNone. Let's remove theNone initialization, and simply use them as type markers.

Fixes#1549

@SineaggiSineaggiforce-pushed theremove-optional-from-two-variables branch 5 times, most recently from737ec27 to8e8b5d5CompareJanuary 27, 2023 21:41
@SineaggiSineaggiforce-pushed theremove-optional-from-two-variables branch from8e8b5d5 tocc71f02CompareJanuary 27, 2023 22:20
@Sineaggi
Copy link
ContributorAuthor

The changes to_get_config_path and_config_reader were necessary as these functions are called during__init__, sometimes beforegit_path is initialized.

Copy link
Member

@ByronByron left a 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. Ifworking_dir cannot be none, I'd like to see what happens with bare repositories. What kind ofworking_dir are they expected to have?

@Sineaggi
Copy link
ContributorAuthor

A bare repo should still have working_dir afaik

Copy link
Member

@ByronByron left a 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 differentworking* 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)
Copy link
Member

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 theworking_tree_dir for completeness? It's easy to confuse both which is what I did apparently. Theworking_dir is the CWD of the git repository, either theworking_tree_dir or thegit_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.

Screenshot 2023-02-02 at 07 15 07

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Ok so the docs inbase.py say that working_tree_dir can return none

@propertydefworking_tree_dir(self)->Optional[PathLike]:""":return: The working tree directory of our git repository. If this is a bare repository, None is returned."""returnself._working_tree_dir

I've added a few more assertions, please check if I understood you.

Copy link
ContributorAuthor

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

@Byron
Copy link
Member

Thanks a lot for bearing with me, I was confused by the difference betweenworking_dir andworking_tree_dir, especially since there is awork_dir ingitoxide (the equivalent ofworking_tree_dir).

And thanks for this great contribution :)!

@ByronByron merged commitc84dde2 intogitpython-developers:mainFeb 2, 2023
@ByronByron added this to thev3.1.31 - Bugfixes milestoneFeb 2, 2023
@SineaggiSineaggi deleted the remove-optional-from-two-variables branchFebruary 2, 2023 21:28
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ByronByronByron requested changes

Assignees
No one assigned
Labels
None yet
Development

Successfully merging this pull request may close these issues.

working_dir has Optional type when it can't be None
2 participants
@Sineaggi@Byron

[8]ページ先頭

©2009-2025 Movatter.jp