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

pkg_resources: Remove type-only _Importer class #11512

Merged
merged 2 commits into from
Mar 1, 2024

Conversation

Avasam
Copy link
Sponsor Collaborator

@Avasam Avasam commented Feb 29, 2024

Extracted from #11455

As I was attempting to merge stubs directly into pkg_resources (setuptools repo), I couldn't figure out what _Importer was actually supposed to be.

After working through the register_* methods, I think I've figured out the correct typing

_NSHandlerType: TypeAlias = Callable[[_Importer, str, str, types.ModuleType], str]
_ModuleLike: TypeAlias = object | types.ModuleType # Any object that optionally has __loader__ or __file__, usually a module
_ProviderFactoryType: TypeAlias = Callable[[_ModuleLike], IResourceProvider]
_DistFinderType: TypeAlias = Callable[[_T, str, bool], Iterable[Distribution]]
Copy link
Sponsor Collaborator Author

@Avasam Avasam Feb 29, 2024

Choose a reason for hiding this comment

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

If it wasn't for the find_nothing method that returns an empty tuple, this would be correct in returning a Generator.
https://github.com/pypa/setuptools/blob/8c45d6e445a8ca5f5a1fd724a80a5c418fe36780/pkg_resources/__init__.py#L2092-L2093

xref pypa/setuptools#4249

Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra JelleZijlstra merged commit 9e5bced into python:main Mar 1, 2024
45 checks passed
@Avasam Avasam deleted the pkg_resources-remove-_Importer branch March 1, 2024 23:45
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.

None yet

2 participants