From d217cb252dab4efc083c1f2a773a124e0ad270a9 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 5 Jan 2025 19:06:28 -0500 Subject: [PATCH 1/4] Remove setuptools/pkg_resources --- stubs/Pygments/METADATA.toml | 2 +- stubs/Pygments/pygments/plugin.pyi | 14 +- stubs/fanstatic/METADATA.toml | 2 +- stubs/fanstatic/fanstatic/registry.pyi | 11 +- .../setuptools/@tests/stubtest_allowlist.txt | 8 - .../@tests/test_cases/check_protocols.py | 36 +- stubs/setuptools/METADATA.toml | 4 +- stubs/setuptools/pkg_resources/__init__.pyi | 543 ------------------ .../_vendored_packaging/__init__.pyi | 8 - .../_vendored_packaging/markers.pyi | 13 - .../_vendored_packaging/requirements.pyi | 14 - .../_vendored_packaging/specifiers.pyi | 66 --- .../_vendored_packaging/version.pyi | 49 -- 13 files changed, 24 insertions(+), 746 deletions(-) delete mode 100644 stubs/setuptools/pkg_resources/__init__.pyi delete mode 100644 stubs/setuptools/pkg_resources/_vendored_packaging/__init__.pyi delete mode 100644 stubs/setuptools/pkg_resources/_vendored_packaging/markers.pyi delete mode 100644 stubs/setuptools/pkg_resources/_vendored_packaging/requirements.pyi delete mode 100644 stubs/setuptools/pkg_resources/_vendored_packaging/specifiers.pyi delete mode 100644 stubs/setuptools/pkg_resources/_vendored_packaging/version.pyi diff --git a/stubs/Pygments/METADATA.toml b/stubs/Pygments/METADATA.toml index 9577e4460ca7..e0ff783259b3 100644 --- a/stubs/Pygments/METADATA.toml +++ b/stubs/Pygments/METADATA.toml @@ -1,6 +1,6 @@ version = "2.18.*" upstream_repository = "https://github.com/pygments/pygments" -requires = ["types-docutils", "types-setuptools"] +requires = ["types-docutils"] partial_stub = true [tool.stubtest] diff --git a/stubs/Pygments/pygments/plugin.pyi b/stubs/Pygments/pygments/plugin.pyi index 308e21957495..e47d66b02c53 100644 --- a/stubs/Pygments/pygments/plugin.pyi +++ b/stubs/Pygments/pygments/plugin.pyi @@ -1,7 +1,7 @@ -from collections.abc import Generator, Iterable +import sys +from collections.abc import Generator from typing import Any -from pkg_resources import EntryPoint from pygments.filter import Filter from pygments.formatter import Formatter from pygments.lexer import Lexer @@ -12,7 +12,15 @@ FORMATTER_ENTRY_POINT: str STYLE_ENTRY_POINT: str FILTER_ENTRY_POINT: str -def iter_entry_points(group_name: str) -> Iterable[EntryPoint]: ... +if sys.version_info >= (3, 10): + from importlib.metadata import EntryPoints + def iter_entry_points(group_name: str) -> EntryPoints: ... + +else: + from importlib.metadata import EntryPoint + + def iter_entry_points(group_name: str) -> tuple[EntryPoint, ...] | list[EntryPoint]: ... + def find_plugin_lexers() -> Generator[type[Lexer], None, None]: ... def find_plugin_formatters() -> Generator[tuple[str, type[Formatter[Any]]], None, None]: ... def find_plugin_styles() -> Generator[tuple[str, type[Style]], None, None]: ... diff --git a/stubs/fanstatic/METADATA.toml b/stubs/fanstatic/METADATA.toml index f0e10ed21df4..1300fe23647d 100644 --- a/stubs/fanstatic/METADATA.toml +++ b/stubs/fanstatic/METADATA.toml @@ -1,3 +1,3 @@ version = "1.4.*" upstream_repository = "https://github.com/zopefoundation/fanstatic" -requires = ["types-setuptools", "types-WebOb"] +requires = ["types-WebOb", "types-setuptools"] diff --git a/stubs/fanstatic/fanstatic/registry.pyi b/stubs/fanstatic/fanstatic/registry.pyi index aa32a8f58d3b..c0a78589feea 100644 --- a/stubs/fanstatic/fanstatic/registry.pyi +++ b/stubs/fanstatic/fanstatic/registry.pyi @@ -1,14 +1,19 @@ from abc import abstractmethod from collections.abc import Iterable from threading import Lock -from typing import Any, ClassVar, Literal, Protocol, TypeVar +from typing import Any, ClassVar, Literal, Protocol, TypeVar, type_check_only from typing_extensions import Self from fanstatic.compiler import Compiler, Minifier from fanstatic.core import Library from fanstatic.injector import InjectorPlugin -from pkg_resources import EntryPoint +# Used to be pkg_resources.EntryPoint, but any EntryPoint-like class with a `load` method works +@type_check_only +class _EntryPoint(Protocol): + def load(self) -> Any: ... # Can be any attribute in the module + +@type_check_only class _HasName(Protocol): @property def name(self) -> str: ... @@ -24,7 +29,7 @@ class Registry(dict[str, _NamedT]): def __init__(self, items: Iterable[_NamedT] = ()) -> None: ... def add(self, item: _NamedT) -> None: ... def load_items_from_entry_points(self) -> None: ... - def make_item_from_entry_point(self, entry_point: EntryPoint) -> Any: ... + def make_item_from_entry_point(self, entry_point: _EntryPoint) -> Any: ... @classmethod def instance(cls) -> Self: ... diff --git a/stubs/setuptools/@tests/stubtest_allowlist.txt b/stubs/setuptools/@tests/stubtest_allowlist.txt index f47062da7093..9869db0f9a0a 100644 --- a/stubs/setuptools/@tests/stubtest_allowlist.txt +++ b/stubs/setuptools/@tests/stubtest_allowlist.txt @@ -1,11 +1,3 @@ -# Is always set in __init__ -pkg_resources.PathMetadata.egg_info -pkg_resources.EggMetadata.loader -pkg_resources.ZipProvider.loader - -# @classmethod alias not handled correctly by stubtest -pkg_resources.ZipManifests.load - # Is a functools.partial, so stubtest says "is not a function" setuptools.modified.newer_pairwise_group setuptools._distutils._modified.newer_pairwise_group diff --git a/stubs/setuptools/@tests/test_cases/check_protocols.py b/stubs/setuptools/@tests/test_cases/check_protocols.py index 66237a4bc2ef..0a6c9a7de399 100644 --- a/stubs/setuptools/@tests/test_cases/check_protocols.py +++ b/stubs/setuptools/@tests/test_cases/check_protocols.py @@ -2,18 +2,7 @@ from typing import Any -from pkg_resources import ( - DefaultProvider, - EggMetadata, - EggProvider, - EmptyProvider, - FileMetadata, - IMetadataProvider, - IResourceProvider, - NullProvider, - PathMetadata, - ZipProvider, -) + from setuptools.command.editable_wheel import EditableStrategy, _LinkTree, _StaticPth, _TopLevelFinder from setuptools.config.expand import EnsurePackagesDiscovered from setuptools.config.pyprojecttoml import _EnsurePackagesDiscovered @@ -21,29 +10,6 @@ # We don't care about the __init__ methods, only about if an instance respects the Protocol _: Any = object() -# Test IMetadataProvider Protocol implementers -metadata_provider: IMetadataProvider -metadata_provider = NullProvider(_) -metadata_provider = EggProvider(_) -metadata_provider = EmptyProvider() -metadata_provider = DefaultProvider(_) -metadata_provider = ZipProvider(_) -metadata_provider = FileMetadata(_) -metadata_provider = PathMetadata(_, _) -metadata_provider = EggMetadata(_) - -# Test IResourceProvider Protocol implementers -resource_provider: IResourceProvider -resource_provider = NullProvider(_) -resource_provider = EggProvider(_) -resource_provider = EmptyProvider() -resource_provider = DefaultProvider(_) -resource_provider = ZipProvider(_) -resource_provider = FileMetadata(_) -resource_provider = PathMetadata(_, _) -resource_provider = EggMetadata(_) - - # Test EditableStrategy Protocol implementers editable_strategy: EditableStrategy editable_strategy = _StaticPth(_, _, _) diff --git a/stubs/setuptools/METADATA.toml b/stubs/setuptools/METADATA.toml index 8b7ea28be095..e0233a8af5b4 100644 --- a/stubs/setuptools/METADATA.toml +++ b/stubs/setuptools/METADATA.toml @@ -1,8 +1,8 @@ version = "75.6.*" upstream_repository = "https://github.com/pypa/setuptools" extra_description = """\ -If using `setuptools >= 71.1` *only* for `pkg_resources`, -you don't need `types-setuptools` since `pkg_resources` is now typed.\ +Given that `pkg_resources` is typed since `setuptools >= 71.1`, \ +it is no longer included with `types-setuptools`. """ [tool.stubtest] diff --git a/stubs/setuptools/pkg_resources/__init__.pyi b/stubs/setuptools/pkg_resources/__init__.pyi deleted file mode 100644 index a4cd7df6396c..000000000000 --- a/stubs/setuptools/pkg_resources/__init__.pyi +++ /dev/null @@ -1,543 +0,0 @@ -# `pkg_resources` package of `types-setuptools` is now obsolete. -# Changes here should be mirrored to https://github.com/pypa/setuptools/tree/main/pkg_resources - -import types -import zipimport -from _typeshed import BytesPath, Incomplete, StrOrBytesPath, StrPath, Unused -from _typeshed.importlib import LoaderProtocol -from collections.abc import Callable, Generator, Iterable, Iterator, Sequence -from io import BytesIO -from itertools import chain -from pkgutil import get_importer as get_importer -from re import Pattern -from typing import IO, Any, ClassVar, Final, Literal, NamedTuple, NoReturn, Protocol, TypeVar, overload -from typing_extensions import Self, TypeAlias -from zipfile import ZipInfo - -from ._vendored_packaging import requirements as _packaging_requirements, version as _packaging_version - -# defined in setuptools -_T = TypeVar("_T") -_DistributionT = TypeVar("_DistributionT", bound=Distribution) -_NestedStr: TypeAlias = str | Iterable[_NestedStr] -_StrictInstallerType: TypeAlias = Callable[[Requirement], _DistributionT] -_InstallerType: TypeAlias = Callable[[Requirement], Distribution | None] -_PkgReqType: TypeAlias = str | Requirement -_EPDistType: TypeAlias = Distribution | _PkgReqType -_MetadataType: TypeAlias = IResourceProvider | None -_ResolvedEntryPoint: TypeAlias = Any # Can be any attribute in the module -_ResourceStream: TypeAlias = Incomplete # A readable file-like object -_ModuleLike: TypeAlias = object | types.ModuleType # Any object that optionally has __loader__ or __file__, usually a module -# Any: Should be _ModuleLike but we end up with issues where _ModuleLike doesn't have _ZipLoaderModule's __loader__ -_ProviderFactoryType: TypeAlias = Callable[[Any], IResourceProvider] -_DistFinderType: TypeAlias = Callable[[_T, str, bool], Iterable[Distribution]] -_NSHandlerType: TypeAlias = Callable[[_T, str, str, types.ModuleType], str | None] - -__all__ = [ - "require", - "run_script", - "get_provider", - "get_distribution", - "load_entry_point", - "get_entry_map", - "get_entry_info", - "iter_entry_points", - "resource_string", - "resource_stream", - "resource_filename", - "resource_listdir", - "resource_exists", - "resource_isdir", - "declare_namespace", - "working_set", - "add_activation_listener", - "find_distributions", - "set_extraction_path", - "cleanup_resources", - "get_default_cache", - "Environment", - "WorkingSet", - "ResourceManager", - "Distribution", - "Requirement", - "EntryPoint", - "ResolutionError", - "VersionConflict", - "DistributionNotFound", - "UnknownExtra", - "ExtractionError", - "PEP440Warning", - "parse_requirements", - "parse_version", - "safe_name", - "safe_version", - "get_platform", - "compatible_platforms", - "yield_lines", - "split_sections", - "safe_extra", - "to_filename", - "invalid_marker", - "evaluate_marker", - "ensure_directory", - "normalize_path", - "EGG_DIST", - "BINARY_DIST", - "SOURCE_DIST", - "CHECKOUT_DIST", - "DEVELOP_DIST", - "IMetadataProvider", - "IResourceProvider", - "FileMetadata", - "PathMetadata", - "EggMetadata", - "EmptyProvider", - "empty_provider", - "NullProvider", - "EggProvider", - "DefaultProvider", - "ZipProvider", - "register_finder", - "register_namespace_handler", - "register_loader_type", - "fixup_namespace_packages", - "get_importer", - "PkgResourcesDeprecationWarning", - "run_main", - "AvailableDistributions", -] - -class _ZipLoaderModule(Protocol): - __loader__: zipimport.zipimporter - -def declare_namespace(packageName: str) -> None: ... -def fixup_namespace_packages(path_item: str, parent: str | None = None) -> None: ... - -class WorkingSet: - entries: list[str] - entry_keys: dict[str | None, list[str]] - by_key: dict[str, Distribution] - normalized_to_canonical_keys: dict[str, str] - callbacks: list[Callable[[Distribution], object]] - def __init__(self, entries: Iterable[str] | None = None) -> None: ... - def add_entry(self, entry: str) -> None: ... - def __contains__(self, dist: Distribution) -> bool: ... - def find(self, req: Requirement) -> Distribution | None: ... - def iter_entry_points(self, group: str, name: str | None = None) -> Generator[EntryPoint, None, None]: ... - def run_script(self, requires: str, script_name: str) -> None: ... - def __iter__(self) -> Iterator[Distribution]: ... - def add(self, dist: Distribution, entry: str | None = None, insert: bool = True, replace: bool = False) -> None: ... - @overload - def resolve( - self, - requirements: Iterable[Requirement], - env: Environment | None, - installer: _StrictInstallerType[_DistributionT], - replace_conflicting: bool = False, - extras: tuple[str, ...] | None = None, - ) -> list[_DistributionT]: ... - @overload - def resolve( - self, - requirements: Iterable[Requirement], - env: Environment | None = None, - *, - installer: _StrictInstallerType[_DistributionT], - replace_conflicting: bool = False, - extras: tuple[str, ...] | None = None, - ) -> list[_DistributionT]: ... - @overload - def resolve( - self, - requirements: Iterable[Requirement], - env: Environment | None = None, - installer: _InstallerType | None = None, - replace_conflicting: bool = False, - extras: tuple[str, ...] | None = None, - ) -> list[Distribution]: ... - @overload - def find_plugins( - self, - plugin_env: Environment, - full_env: Environment | None, - installer: _StrictInstallerType[_DistributionT], - fallback: bool = True, - ) -> tuple[list[_DistributionT], dict[Distribution, Exception]]: ... - @overload - def find_plugins( - self, - plugin_env: Environment, - full_env: Environment | None = None, - *, - installer: _StrictInstallerType[_DistributionT], - fallback: bool = True, - ) -> tuple[list[_DistributionT], dict[Distribution, Exception]]: ... - @overload - def find_plugins( - self, - plugin_env: Environment, - full_env: Environment | None = None, - installer: _InstallerType | None = None, - fallback: bool = True, - ) -> tuple[list[Distribution], dict[Distribution, Exception]]: ... - def require(self, *requirements: _NestedStr) -> Sequence[Distribution]: ... - def subscribe(self, callback: Callable[[Distribution], Unused], existing: bool = True) -> None: ... - -class Environment: - def __init__( - self, search_path: Iterable[str] | None = None, platform: str | None = ..., python: str | None = ... - ) -> None: ... - def can_add(self, dist: Distribution) -> bool: ... - def remove(self, dist: Distribution) -> None: ... - def scan(self, search_path: Iterable[str] | None = None) -> None: ... - def __getitem__(self, project_name: str) -> list[Distribution]: ... - def add(self, dist: Distribution) -> None: ... - @overload - def best_match( - self, - req: Requirement, - working_set: WorkingSet, - installer: _StrictInstallerType[_DistributionT], - replace_conflicting: bool = False, - ) -> _DistributionT: ... - @overload - def best_match( - self, - req: Requirement, - working_set: WorkingSet, - installer: _InstallerType | None = None, - replace_conflicting: bool = False, - ) -> Distribution | None: ... - @overload - def obtain(self, requirement: Requirement, installer: _StrictInstallerType[_DistributionT]) -> _DistributionT: ... - @overload - def obtain(self, requirement: Requirement, installer: Callable[[Requirement], None] | None = None) -> None: ... - @overload - def obtain(self, requirement: Requirement, installer: _InstallerType | None = None) -> Distribution | None: ... - def __iter__(self) -> Iterator[str]: ... - def __iadd__(self, other: Distribution | Environment) -> Self: ... - def __add__(self, other: Distribution | Environment) -> Self: ... - -AvailableDistributions = Environment - -def parse_requirements(strs: _NestedStr) -> Iterator[Requirement]: ... - -class RequirementParseError(_packaging_requirements.InvalidRequirement): ... - -class Requirement(_packaging_requirements.Requirement): - unsafe_name: str - project_name: str - key: str - # packaging.requirements.Requirement uses a set for its extras. setuptools/pkg_resources uses a variable-length tuple - extras: tuple[str, ...] # type: ignore[assignment] - specs: list[tuple[str, str]] - def __init__(self, requirement_string: str) -> None: ... - def __eq__(self, other: object) -> bool: ... - def __contains__(self, item: Distribution | str | tuple[str, ...]) -> bool: ... - @staticmethod - def parse(s: str | Iterable[str]) -> Requirement: ... - -def load_entry_point(dist: _EPDistType, group: str, name: str) -> _ResolvedEntryPoint: ... -@overload -def get_entry_map(dist: _EPDistType, group: None = None) -> dict[str, dict[str, EntryPoint]]: ... -@overload -def get_entry_map(dist: _EPDistType, group: str) -> dict[str, EntryPoint]: ... -def get_entry_info(dist: _EPDistType, group: str, name: str) -> EntryPoint | None: ... - -class EntryPoint: - name: str - module_name: str - attrs: tuple[str, ...] - extras: tuple[str, ...] - dist: Distribution | None - def __init__( - self, name: str, module_name: str, attrs: Iterable[str] = (), extras: Iterable[str] = (), dist: Distribution | None = None - ) -> None: ... - @overload - def load( - self, require: Literal[True] = True, env: Environment | None = None, installer: _InstallerType | None = None - ) -> _ResolvedEntryPoint: ... - @overload - def load( - self, require: Literal[False], *args: Environment | _InstallerType | None, **kwargs: Environment | _InstallerType | None - ) -> _ResolvedEntryPoint: ... - def resolve(self) -> _ResolvedEntryPoint: ... - def require(self, env: Environment | None = None, installer: _InstallerType | None = None) -> None: ... - pattern: ClassVar[Pattern[str]] - @classmethod - def parse(cls, src: str, dist: Distribution | None = None) -> Self: ... - @classmethod - def parse_group(cls, group: str, lines: _NestedStr, dist: Distribution | None = None) -> dict[str, Self]: ... - @classmethod - def parse_map( - cls, data: str | Iterable[str] | dict[str, str | Iterable[str]], dist: Distribution | None = None - ) -> dict[str, dict[str, Self]]: ... - -def find_distributions(path_item: str, only: bool = False) -> Generator[Distribution, None, None]: ... -def find_eggs_in_zip(importer: zipimport.zipimporter, path_item: str, only: bool = False) -> Iterator[Distribution]: ... -def find_nothing(importer: object | None, path_item: str | None, only: bool | None = False) -> tuple[Distribution, ...]: ... -def find_on_path(importer: object | None, path_item: str, only: bool = False) -> Generator[Distribution, None, None]: ... -def dist_factory(path_item: StrPath, entry: str, only: bool) -> Callable[[str], Iterable[Distribution]]: ... - -class NoDists: - def __bool__(self) -> Literal[False]: ... - def __call__(self, fullpath: Unused) -> Iterator[Distribution]: ... - -@overload -def get_distribution(dist: _DistributionT) -> _DistributionT: ... -@overload -def get_distribution(dist: _PkgReqType) -> Distribution: ... - -PY_MAJOR: Final[str] -EGG_DIST: Final = 3 -BINARY_DIST: Final = 2 -SOURCE_DIST: Final = 1 -CHECKOUT_DIST: Final = 0 -DEVELOP_DIST: Final = -1 - -class ResourceManager: - extraction_path: str | None - cached_files: Incomplete - def resource_exists(self, package_or_requirement: _PkgReqType, resource_name: str) -> bool: ... - def resource_isdir(self, package_or_requirement: _PkgReqType, resource_name: str) -> bool: ... - def resource_filename(self, package_or_requirement: _PkgReqType, resource_name: str) -> str: ... - def resource_stream(self, package_or_requirement: _PkgReqType, resource_name: str) -> IO[bytes]: ... - def resource_string(self, package_or_requirement: _PkgReqType, resource_name: str) -> bytes: ... - def resource_listdir(self, package_or_requirement: _PkgReqType, resource_name: str) -> list[str]: ... - def extraction_error(self) -> NoReturn: ... - def get_cache_path(self, archive_name: str, names: Iterable[StrPath] = ()) -> str: ... - def postprocess(self, tempname: StrOrBytesPath, filename: StrOrBytesPath) -> None: ... - def set_extraction_path(self, path: str) -> None: ... - def cleanup_resources(self, force: bool = False) -> list[str]: ... - -@overload -def get_provider(moduleOrReq: str) -> IResourceProvider: ... -@overload -def get_provider(moduleOrReq: Requirement) -> Distribution: ... - -class IMetadataProvider(Protocol): - def has_metadata(self, name: str) -> bool: ... - def get_metadata(self, name: str) -> str: ... - def get_metadata_lines(self, name: str) -> Iterator[str]: ... - def metadata_isdir(self, name: str) -> bool: ... - def metadata_listdir(self, name: str) -> list[str]: ... - def run_script(self, script_name: str, namespace: dict[str, Any]) -> None: ... - -class ResolutionError(Exception): ... - -class VersionConflict(ResolutionError): - def __init__(self, dist: Distribution, req: Requirement, /, *args: object) -> None: ... - @property - def dist(self) -> Distribution: ... - @property - def req(self) -> Requirement: ... - def report(self) -> str: ... - def with_context(self, required_by: set[str]) -> Self | ContextualVersionConflict: ... - -class ContextualVersionConflict(VersionConflict): - def __init__(self, dist: Distribution, req: Requirement, required_by: set[str], /, *args: object) -> None: ... - @property - def required_by(self) -> set[str]: ... - -class DistributionNotFound(ResolutionError): - def __init__(self, req: Requirement, requirers: set[str] | None, /, *args: object) -> None: ... - @property - def req(self) -> Requirement: ... - @property - def requirers(self) -> set[str] | None: ... - @property - def requirers_str(self) -> str: ... - def report(self) -> str: ... - -class UnknownExtra(ResolutionError): ... - -class ExtractionError(Exception): - manager: ResourceManager - cache_path: str - original_error: BaseException | None - -def register_finder(importer_type: type[_T], distribution_finder: _DistFinderType[_T]) -> None: ... -def register_loader_type(loader_type: type[_ModuleLike], provider_factory: _ProviderFactoryType) -> None: ... -def resolve_egg_link(path: str) -> Iterable[Distribution]: ... -def register_namespace_handler(importer_type: type[_T], namespace_handler: _NSHandlerType[_T]) -> None: ... - -class IResourceProvider(IMetadataProvider, Protocol): - def get_resource_filename(self, manager: ResourceManager, resource_name: str) -> StrPath: ... - def get_resource_stream(self, manager: ResourceManager, resource_name: str) -> _ResourceStream: ... - def get_resource_string(self, manager: ResourceManager, resource_name: str) -> bytes: ... - def has_resource(self, resource_name: str) -> bool: ... - def resource_isdir(self, resource_name: str) -> bool: ... - def resource_listdir(self, resource_name: str) -> list[str]: ... - -def invalid_marker(text: str) -> SyntaxError | Literal[False]: ... -def evaluate_marker(text: str, extra: Incomplete | None = None) -> bool: ... - -class NullProvider: - egg_name: str | None - egg_info: str | None - loader: LoaderProtocol | None - module_path: str - - def __init__(self, module: _ModuleLike) -> None: ... - def get_resource_filename(self, manager: ResourceManager, resource_name: str) -> str: ... - def get_resource_stream(self, manager: ResourceManager, resource_name: str) -> BytesIO: ... - def get_resource_string(self, manager: ResourceManager, resource_name: str) -> bytes: ... - def has_resource(self, resource_name: str) -> bool: ... - def has_metadata(self, name: str) -> bool: ... - def get_metadata(self, name: str) -> str: ... - def get_metadata_lines(self, name: str) -> chain[str]: ... - def resource_isdir(self, resource_name: str) -> bool: ... - def metadata_isdir(self, name: str) -> bool: ... - def resource_listdir(self, resource_name: str) -> list[str]: ... - def metadata_listdir(self, name: str) -> list[str]: ... - def run_script(self, script_name: str, namespace: dict[str, Any]) -> None: ... - -# Doesn't actually extend NullProvider, solves a typing issue in pytype_test.py -class Distribution(NullProvider): - PKG_INFO: ClassVar[str] - project_name: str - py_version: str | None - platform: str | None - location: str | None - precedence: int - def __init__( - self, - location: str | None = None, - metadata: _MetadataType = None, - project_name: str | None = None, - version: str | None = None, - py_version: str | None = ..., - platform: str | None = None, - precedence: int = 3, - ) -> None: ... - @classmethod - def from_location( - cls, location: str, basename: StrPath, metadata: _MetadataType = None, *, precedence: int = 3 - ) -> Distribution: ... - @property - def hashcmp(self) -> tuple[parse_version, int, str, str | None, str, str]: ... - def __hash__(self) -> int: ... - def __lt__(self, other: Distribution) -> bool: ... - def __le__(self, other: Distribution) -> bool: ... - def __gt__(self, other: Distribution) -> bool: ... - def __ge__(self, other: Distribution) -> bool: ... - def __eq__(self, other: object) -> bool: ... - def __ne__(self, other: object) -> bool: ... - @property - def key(self) -> str: ... - @property - def parsed_version(self) -> _packaging_version.Version: ... - @property - def version(self) -> str: ... - def requires(self, extras: Iterable[str] = ()) -> list[Requirement]: ... - def activate(self, path: list[str] | None = None, replace: bool = False) -> None: ... - def egg_name(self) -> str: ... # type: ignore[override] # supertype's egg_name is a variable, not a method - def __getattr__(self, attr: str) -> Any: ... # Delegate all unrecognized public attributes to .metadata provider - @classmethod - def from_filename(cls, filename: StrPath, metadata: _MetadataType = None, *, precedence: int = 3) -> Distribution: ... - def as_requirement(self) -> Requirement: ... - def load_entry_point(self, group: str, name: str) -> _ResolvedEntryPoint: ... - @overload - def get_entry_map(self, group: None = None) -> dict[str, dict[str, EntryPoint]]: ... - @overload - def get_entry_map(self, group: str) -> dict[str, EntryPoint]: ... - def get_entry_info(self, group: str, name: str) -> EntryPoint | None: ... - def insert_on(self, path: list[str], loc: Incomplete | None = None, replace: bool = False) -> None: ... - def check_version_conflict(self) -> None: ... - def has_version(self) -> bool: ... - def clone(self, **kw: str | int | IResourceProvider | None) -> Requirement: ... - @property - def extras(self) -> list[str]: ... - -class DistInfoDistribution(Distribution): - PKG_INFO: ClassVar[Literal["METADATA"]] - EQEQ: ClassVar[Pattern[str]] - -class EggProvider(NullProvider): - egg_root: str - -class DefaultProvider(EggProvider): ... - -class PathMetadata(DefaultProvider): - egg_info: str - module_path: str - def __init__(self, path: str, egg_info: str) -> None: ... - -class ZipProvider(EggProvider): - eagers: list[str] | None - zip_pre: str - # ZipProvider's loader should always be a zipimporter - loader: zipimport.zipimporter - def __init__(self, module: _ZipLoaderModule) -> None: ... - @property - def zipinfo(self) -> dict[str, ZipInfo]: ... - -class EggMetadata(ZipProvider): - loader: zipimport.zipimporter - module_path: str - def __init__(self, importer: zipimport.zipimporter) -> None: ... - -class EmptyProvider(NullProvider): - # A special case, we don't want all Providers inheriting from NullProvider to have a potentially None module_path - module_path: str | None # type:ignore[assignment] - def __init__(self) -> None: ... - -empty_provider: EmptyProvider - -class ZipManifests(dict[str, MemoizedZipManifests.manifest_mod]): - @classmethod - def build(cls, path: str) -> dict[str, ZipInfo]: ... - load = build - -class MemoizedZipManifests(ZipManifests): - class manifest_mod(NamedTuple): - manifest: dict[str, ZipInfo] - mtime: float - - def load(self, path: str) -> dict[str, ZipInfo]: ... # type: ignore[override] - -class FileMetadata(EmptyProvider): - path: StrPath - def __init__(self, path: StrPath) -> None: ... - -class PEP440Warning(RuntimeWarning): ... - -parse_version = _packaging_version.Version - -def yield_lines(iterable: _NestedStr) -> chain[str]: ... -def split_sections(s: _NestedStr) -> Generator[tuple[str | None, list[str]], None, None]: ... -def safe_name(name: str) -> str: ... -def safe_version(version: str) -> str: ... -def safe_extra(extra: str) -> str: ... -def to_filename(name: str) -> str: ... -def get_build_platform() -> str: ... - -get_platform = get_build_platform - -def get_supported_platform() -> str: ... -def compatible_platforms(provided: str | None, required: str | None) -> bool: ... -def get_default_cache() -> str: ... -def ensure_directory(path: StrOrBytesPath) -> None: ... -@overload -def normalize_path(filename: StrPath) -> str: ... -@overload -def normalize_path(filename: BytesPath) -> bytes: ... - -class PkgResourcesDeprecationWarning(Warning): ... - -__resource_manager: ResourceManager # Doesn't exist at runtime -resource_exists = __resource_manager.resource_exists -resource_isdir = __resource_manager.resource_isdir -resource_filename = __resource_manager.resource_filename -resource_stream = __resource_manager.resource_stream -resource_string = __resource_manager.resource_string -resource_listdir = __resource_manager.resource_listdir -set_extraction_path = __resource_manager.set_extraction_path -cleanup_resources = __resource_manager.cleanup_resources - -working_set: WorkingSet -require = working_set.require -iter_entry_points = working_set.iter_entry_points -add_activation_listener = working_set.subscribe -run_script = working_set.run_script -run_main = run_script diff --git a/stubs/setuptools/pkg_resources/_vendored_packaging/__init__.pyi b/stubs/setuptools/pkg_resources/_vendored_packaging/__init__.pyi deleted file mode 100644 index 1981f2d9b273..000000000000 --- a/stubs/setuptools/pkg_resources/_vendored_packaging/__init__.pyi +++ /dev/null @@ -1,8 +0,0 @@ -__title__: str -__summary__: str -__uri__: str -__version__: str -__author__: str -__email__: str -__license__: str -__copyright__: str diff --git a/stubs/setuptools/pkg_resources/_vendored_packaging/markers.pyi b/stubs/setuptools/pkg_resources/_vendored_packaging/markers.pyi deleted file mode 100644 index 0a7acbbf3a75..000000000000 --- a/stubs/setuptools/pkg_resources/_vendored_packaging/markers.pyi +++ /dev/null @@ -1,13 +0,0 @@ -__all__ = ["InvalidMarker", "UndefinedComparison", "UndefinedEnvironmentName", "Marker", "default_environment"] - -class InvalidMarker(ValueError): ... -class UndefinedComparison(ValueError): ... -class UndefinedEnvironmentName(ValueError): ... - -def default_environment() -> dict[str, str]: ... - -class Marker: - def __init__(self, marker: str) -> None: ... - def __hash__(self) -> int: ... - def __eq__(self, other: object) -> bool: ... - def evaluate(self, environment: dict[str, str] | None = None) -> bool: ... diff --git a/stubs/setuptools/pkg_resources/_vendored_packaging/requirements.pyi b/stubs/setuptools/pkg_resources/_vendored_packaging/requirements.pyi deleted file mode 100644 index 4f909fa75a23..000000000000 --- a/stubs/setuptools/pkg_resources/_vendored_packaging/requirements.pyi +++ /dev/null @@ -1,14 +0,0 @@ -from .markers import Marker -from .specifiers import SpecifierSet - -class InvalidRequirement(ValueError): ... - -class Requirement: - name: str - url: str | None - extras: set[str] - specifier: SpecifierSet - marker: Marker | None - def __init__(self, requirement_str: str) -> None: ... - def __hash__(self) -> int: ... - def __eq__(self, other: object) -> bool: ... diff --git a/stubs/setuptools/pkg_resources/_vendored_packaging/specifiers.pyi b/stubs/setuptools/pkg_resources/_vendored_packaging/specifiers.pyi deleted file mode 100644 index ec86ea306e74..000000000000 --- a/stubs/setuptools/pkg_resources/_vendored_packaging/specifiers.pyi +++ /dev/null @@ -1,66 +0,0 @@ -import abc -from collections.abc import Iterable, Iterator -from typing import TypeVar -from typing_extensions import TypeAlias - -from .version import Version - -# These exist at runtime, hence the public names -UnparsedVersion: TypeAlias = Version | str -UnparsedVersionVar = TypeVar("UnparsedVersionVar", bound=UnparsedVersion) # noqa: Y001 - -class InvalidSpecifier(ValueError): ... - -class BaseSpecifier(metaclass=abc.ABCMeta): - @abc.abstractmethod - def __str__(self) -> str: ... - @abc.abstractmethod - def __hash__(self) -> int: ... - @abc.abstractmethod - def __eq__(self, other: object) -> bool: ... - @property - @abc.abstractmethod - def prereleases(self) -> bool | None: ... - @prereleases.setter - def prereleases(self, value: bool) -> None: ... - @abc.abstractmethod - def contains(self, item: str, prereleases: bool | None = None) -> bool: ... - @abc.abstractmethod - def filter(self, iterable: Iterable[UnparsedVersionVar], prereleases: bool | None = None) -> Iterator[UnparsedVersionVar]: ... - -class Specifier(BaseSpecifier): - def __init__(self, spec: str = "", prereleases: bool | None = None) -> None: ... - @property # type: ignore[override] - def prereleases(self) -> bool: ... - @prereleases.setter - def prereleases(self, value: bool) -> None: ... - @property - def operator(self) -> str: ... - @property - def version(self) -> str: ... - def __str__(self) -> str: ... # noqa: Y029 # needed as it's abstract on the superclass - def __hash__(self) -> int: ... - def __eq__(self, other: object) -> bool: ... - def __contains__(self, item: Version | str) -> bool: ... - def contains(self, item: UnparsedVersion, prereleases: bool | None = None) -> bool: ... - def filter(self, iterable: Iterable[UnparsedVersionVar], prereleases: bool | None = None) -> Iterator[UnparsedVersionVar]: ... - -class SpecifierSet(BaseSpecifier): - def __init__(self, spec: str = "", prereleases: bool | None = None) -> None: ... - @property - def prereleases(self) -> bool | None: ... - @prereleases.setter - def prereleases(self, value: bool) -> None: ... - @property - def operator(self) -> str: ... - @property - def version(self) -> str: ... - def __str__(self) -> str: ... # noqa: Y029 # needed as it's abstract on the superclass - def __hash__(self) -> int: ... - def __and__(self, other: SpecifierSet | str) -> SpecifierSet: ... - def __len__(self) -> int: ... - def __iter__(self) -> Iterator[Specifier]: ... - def __eq__(self, other: object) -> bool: ... - def __contains__(self, item: UnparsedVersion) -> bool: ... - def contains(self, item: UnparsedVersion, prereleases: bool | None = None, installed: bool | None = None) -> bool: ... - def filter(self, iterable: Iterable[UnparsedVersionVar], prereleases: bool | None = None) -> Iterator[UnparsedVersionVar]: ... diff --git a/stubs/setuptools/pkg_resources/_vendored_packaging/version.pyi b/stubs/setuptools/pkg_resources/_vendored_packaging/version.pyi deleted file mode 100644 index 05e45eea17c7..000000000000 --- a/stubs/setuptools/pkg_resources/_vendored_packaging/version.pyi +++ /dev/null @@ -1,49 +0,0 @@ -from typing import Final - -__all__ = ["VERSION_PATTERN", "parse", "Version", "InvalidVersion"] - -def parse(version: str) -> Version: ... - -class InvalidVersion(ValueError): ... - -VERSION_PATTERN: Final[str] - -class _BaseVersion: - def __hash__(self) -> int: ... - def __lt__(self, other: _BaseVersion) -> bool: ... - def __le__(self, other: _BaseVersion) -> bool: ... - def __ge__(self, other: _BaseVersion) -> bool: ... - def __gt__(self, other: _BaseVersion) -> bool: ... - def __eq__(self, other: object) -> bool: ... - def __ne__(self, other: object) -> bool: ... - -class Version(_BaseVersion): - def __init__(self, version: str) -> None: ... - @property - def epoch(self) -> int: ... - @property - def release(self) -> tuple[int, ...]: ... - @property - def pre(self) -> tuple[str, int] | None: ... - @property - def post(self) -> int | None: ... - @property - def dev(self) -> int | None: ... - @property - def local(self) -> str | None: ... - @property - def public(self) -> str: ... - @property - def base_version(self) -> str: ... - @property - def is_prerelease(self) -> bool: ... - @property - def is_postrelease(self) -> bool: ... - @property - def is_devrelease(self) -> bool: ... - @property - def major(self) -> int: ... - @property - def minor(self) -> int: ... - @property - def micro(self) -> int: ... From 96be22d1888b015f51aa9464671c8916e73114a3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 6 Jan 2025 00:09:28 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/setuptools/@tests/test_cases/check_protocols.py | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/setuptools/@tests/test_cases/check_protocols.py b/stubs/setuptools/@tests/test_cases/check_protocols.py index 0a6c9a7de399..20573855ac44 100644 --- a/stubs/setuptools/@tests/test_cases/check_protocols.py +++ b/stubs/setuptools/@tests/test_cases/check_protocols.py @@ -2,7 +2,6 @@ from typing import Any - from setuptools.command.editable_wheel import EditableStrategy, _LinkTree, _StaticPth, _TopLevelFinder from setuptools.config.expand import EnsurePackagesDiscovered from setuptools.config.pyprojecttoml import _EnsurePackagesDiscovered From 5d769942e3bb867b392f96f919847050de81fa83 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 5 Jan 2025 20:08:07 -0500 Subject: [PATCH 3/4] Fix some CI issues --- stubs/setuptools/@tests/stubtest_allowlist.txt | 1 - stubs/setuptools/METADATA.toml | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/setuptools/@tests/stubtest_allowlist.txt b/stubs/setuptools/@tests/stubtest_allowlist.txt index 9869db0f9a0a..a08421ff5029 100644 --- a/stubs/setuptools/@tests/stubtest_allowlist.txt +++ b/stubs/setuptools/@tests/stubtest_allowlist.txt @@ -104,4 +104,3 @@ setuptools.config._validate_pyproject.* setuptools.compat.* setuptools.command.build_py.build_py.existing_egg_info_dir .+?\.tests.* -.+?\._vendor.* diff --git a/stubs/setuptools/METADATA.toml b/stubs/setuptools/METADATA.toml index e0233a8af5b4..eddf89618d09 100644 --- a/stubs/setuptools/METADATA.toml +++ b/stubs/setuptools/METADATA.toml @@ -4,6 +4,7 @@ extra_description = """\ Given that `pkg_resources` is typed since `setuptools >= 71.1`, \ it is no longer included with `types-setuptools`. """ +requires = ["setuptools"] # For pkg_resources [tool.stubtest] # darwin is equivalent to linux for OS-specific methods From f5ead36135c17753a51975491df08d624671d26b Mon Sep 17 00:00:00 2001 From: Avasam Date: Sun, 5 Jan 2025 20:44:42 -0500 Subject: [PATCH 4/4] Discard changes to stubs/fanstatic/METADATA.toml --- stubs/fanstatic/METADATA.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/fanstatic/METADATA.toml b/stubs/fanstatic/METADATA.toml index 1300fe23647d..f0e10ed21df4 100644 --- a/stubs/fanstatic/METADATA.toml +++ b/stubs/fanstatic/METADATA.toml @@ -1,3 +1,3 @@ version = "1.4.*" upstream_repository = "https://github.com/zopefoundation/fanstatic" -requires = ["types-WebOb", "types-setuptools"] +requires = ["types-setuptools", "types-WebOb"]