Skip to content
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

Add type annotations to pip._internal.utils.filesystem #5769

Closed
wants to merge 1 commit into from

Conversation

watilde
Copy link

@watilde watilde commented Sep 6, 2018

Links to #4748, I just added types to a small file.

Once this passed, I'm going to add more in next PRs, thanks!

Copy link
Member

@pfmoore pfmoore left a comment

Choose a reason for hiding this comment

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

I'm not an expert in type annotations (I've barely used them) but I'd hope that whatever annotations we do add should be understandable by non-experts, so hopefully that doesn't disqualify me from commenting :-)

I'd rather we just annotated function signatures, and didn't try to sprinkle annotations through the body of the function. Certainly there seem to be some annotations here that don't really seem to add anything useful.


def check_path_owner(path):
# type: (str) -> List[str]
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this wrong? It says we're returning a List[str] but we actually return a boolean...

Copy link
Member

Choose a reason for hiding this comment

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

Yep. It is. This should be (str) -> bool and the List import is redundant once this change is made.

except OSError:
return False
return path_uid == 0
return path_uid == 0 # type: int
Copy link
Member

Choose a reason for hiding this comment

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

This seems like an odd annotation. What's being annotated? The expression? (Which is obviously boolean).

@pradyunsg
Copy link
Member

I'd hope that whatever annotations we do add should be understandable by non-experts, so hopefully that doesn't disqualify me from commenting :-)

Yep. IMO the point of this exercise is those who read/use the code should get a quick summary of what types to expect from the type annotation.

@pradyunsg
Copy link
Member

Closing since #5932 covers this. Thanks for the PR @watilde!

@pradyunsg pradyunsg closed this Oct 30, 2018
@lock
Copy link

lock bot commented May 31, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label May 31, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 31, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants