10000 `pytype_test.py`: Fix typechecking errors by AlexWaygood · Pull Request #9847 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

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

Closed
wants to merge 2 commits into from
Closed

Conversation

AlexWaygood
Copy link
Member
@AlexWaygood AlexWaygood commented Mar 6, 2023

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

@AlexWaygood AlexWaygood marked this pull request as ready for review March 6, 2023 17:41
@Avasam
Copy link
Collaborator
Avasam commented Mar 6, 2023

Uh, I thought this was supposed to be fixed by #9747, not produce different errors 🤔(that was kindof the whole point of that PR)

Comment on lines +164 to +165
pkg_resources.get_distribution(pkg).egg_info, # type: ignore[arg-type] # pyright: ignore[reportGeneralTypeIssues]
"top_level.txt", # pyright: ignore[reportGeneralTypeIssues]
Copy link
Collaborator
@Avasam Avasam Mar 6, 2023

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.

Suggested change
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")

Copy link
Member Author

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 😀

Copy link
Collaborator

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 ..."

@AlexWaygood
Copy link
Member Author

Closing in favour of #9849

@AlexWaygood AlexWaygood closed this Mar 6, 2023
@AlexWaygood AlexWaygood deleted the AlexWaygood-patch-1 branch March 6, 2023 18:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0