-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
pytype_test.py: Fix typechecking errors
#9847
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
Conversation
|
Uh, I thought this was supposed to be fixed by #9747, not produce different errors 🤔(that was kindof the whole point of that PR) |
| pkg_resources.get_distribution(pkg).egg_info, # type: ignore[arg-type] # pyright: ignore[reportGeneralTypeIssues] | ||
| "top_level.txt", # pyright: ignore[reportGeneralTypeIssues] |
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.
Ah, right, because Distribution.egg_info can be None.
Something like this? The code already implicitly made this assert assumption.
| pkg_resources.get_distribution(pkg).egg_info, # type: ignore[arg-type] # pyright: ignore[reportGeneralTypeIssues] | |
| "top_level.txt", # pyright: ignore[reportGeneralTypeIssues] | |
| egg_info = pkg_resources.get_distribution(pkg).egg_info | |
| assert isinstance(egg_info, str) | |
| # See https://stackoverflow.com/a/54853084 | |
| top_level_file = os.path.join(egg_info, "top_level.txt") |
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.
Wanna make another PR? I'll happily close this one if you can get the CI green in a more principled way 😀
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.
There: #9849 (comment) Feel free to suggest changes if you want a different assert (truthy, is not None, ...) or a message with said assert "Missing egg_info on package ..."
|
Closing in favour of #9849 |
The type checkers have changed their minds about why they don't like this snippet of code, following the new release of
types-setuptools, following #9747(Failing CI run here: https://github.com/python/typeshed/actions/runs/4346178794)
Cc. @Avasam