8000 Update pkg_resources-stubs for use in pytype_test by Avasam · Pull Request #9747 · python/typeshed · GitHub
[go: up one dir, main page]

Skip to content

Update pkg_resources-stubs for use in pytype_test #9747

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

Merged
merged 10 commits into from
Mar 6, 2023
Merged
Prev Previous commit
Next Next commit
stubtest fixes
  • Loading branch information
Avasam committed Feb 23, 2023
commit a08efa238d6fde993fbd9552a939f03372515000
7 changes: 4 additions & 3 deletions stubs/setuptools/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ pkg_resources.Distribution.__cmp__
pkg_resources.Distribution.activate
pkg_resources.Distribution.get_entry_map
pkg_resources.EggMetadata.__init__
pkg_resources.EggProvider.__init__
pkg_resources.Environment.best_match
pkg_resources.Environment.obtain
pkg_resources.FileMetadata.__init__
Expand All @@ -13,12 +12,10 @@ pkg_resources.IMetadataProvider.metadata_isdir
pkg_resources.IMetadataProvider.metadata_listdir
pkg_resources.IMetadataProvider.run_script
pkg_resources.IResourceManager
pkg_resources.NullProvider.__init__
pkg_resources.Requirement.__init__
pkg_resources.WorkingSet.find_plugins
pkg_resources.WorkingSet.resolve
pkg_resources.WorkingSet.subscribe
pkg_resources.ZipProvider.__init__
pkg_resources.declare_namespace
pkg_resources.fixup_namespace_packages
pkg_resources.get_entry_map
Expand All @@ -27,6 +24,10 @@ pkg_resources.py31compat
pkg_resources.split_sections
pkg_resources.to_filename

# Is always set in __init__
pkg_resources.PathMetadata.egg_info
pkg_resources.EggMetadata.loader

# Only present if docutils is installed
setuptools._distutils.command.check.SilentReporter

Expand Down
14 changes: 10 additions & 4 deletions stubs/setuptools/pkg_resources/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ class NullProvider:
egg_name: str | None
egg_info: str | None
loader: types._LoaderProtocol | None
module_path: str | None
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
module_path: str | None
module_path: str

The initializer unconditionally sets it to a string.

Copy link
Collaborator Author
@Avasam Avasam Feb 25, 2023

Choose a reason for hiding this comment

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

EmptyProvider sets it explicitely to None and overrides __init__

Should I keep module_path: str | None for sublcassing. Or add # type: ignore[assignment] to EmptyProvider.module_path ?

Especially considering this comment: #9747 (comment)


def __init__(self, module) C936 -> None: ...
def get_resource_filename(self, manager, resource_name) -> str: ...
Expand All @@ -274,22 +275,27 @@ class NullProvider:
def run_script(self, script_name: str, namespace: dict[str, Any]) -> None: ...

class EggProvider(NullProvider):
egg_name: str
egg_info: str
egg_root: str

class DefaultProvider(EggProvider): ...

class PathMetadata(DefaultProvider, IResourceProvider):
egg_info: str
module_path: str
def __init__(self, path: str, egg_info: str) -> None: ...

class ZipProvider(EggProvider): ...
class ZipProvider(EggProvider):
eagers: list[str] | None
zip_pre: str

class EggMetadata(ZipProvider, IResourceProvider):
loader: types._LoaderProtocol
Copy link
Member

Choose a reason for hiding this comment

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

This comes from the zipimporter argument to __init__ so the types should match.

module_path: str
def __init__(self, zipimporter: zipimport.zipimporter) -> None: ...

class EmptyProvider(NullProvider): ...
class EmptyProvider(NullProvider):
module_path: None
def __init__(self) -> None: ...

empty_provider: EmptyProvider

Expand Down
0