From 9797249f50d45cfeccaf7fbe04d3f290ef453e6b Mon Sep 17 00:00:00 2001 From: Avasam <samuel.06@hotmail.com> Date: Wed, 28 Feb 2024 20:20:21 -0500 Subject: [PATCH] `pkg_resources`: Reorder names to be closer to implementation (#11493) --- stubs/setuptools/pkg_resources/__init__.pyi | 121 ++++++++++---------- 1 file changed, 60 insertions(+), 61 deletions(-) diff --git a/stubs/setuptools/pkg_resources/__init__.pyi b/stubs/setuptools/pkg_resources/__init__.pyi index e26bd8142d6e..d15e1c9a7357 100644 --- a/stubs/setuptools/pkg_resources/__init__.pyi +++ b/stubs/setuptools/pkg_resources/__init__.pyi @@ -27,13 +27,13 @@ def fixup_namespace_packages(path_item: str, parent=None) -> None: ... class WorkingSet: entries: list[str] def __init__(self, entries: Iterable[str] | None = None) -> None: ... - def require(self, *requirements: _NestedStr) -> Sequence[Distribution]: ... - def run_script(self, requires: str, script_name: str) -> None: ... - def iter_entry_points(self, group: str, name: str | None = None) -> Generator[EntryPoint, None, None]: ... def add_entry(self, entry: str) -> None: ... def __contains__(self, dist: Distribution) -> bool: ... - def __iter__(self) -> Iterator[Distribution]: ... 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: ... def resolve( self, requirements: Iterable[Requirement], @@ -42,31 +42,28 @@ class WorkingSet: replace_conflicting: bool = False, extras=None, ) -> list[Distribution]: ... - def add(self, dist: Distribution, entry: str | None = None, insert: bool = True, replace: bool = False) -> None: ... - def subscribe(self, callback: Callable[[Distribution], object], existing: bool = True) -> None: ... def find_plugins( self, plugin_env: Environment, full_env: Environment | None = None, installer=None, fallback: bool = True ) -> tuple[list[Distribution], dict[Distribution, Exception]]: ... + def require(self, *requirements: _NestedStr) -> Sequence[Distribution]: ... + def subscribe(self, callback: Callable[[Distribution], object], existing: bool = True) -> None: ... working_set: WorkingSet - require = working_set.require -run_script = working_set.run_script -run_main = run_script iter_entry_points = working_set.iter_entry_points add_activation_listener = working_set.subscribe +run_script = working_set.run_script +run_main = run_script class Environment: def __init__( self, search_path: Sequence[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: Sequence[str] | None = None) -> None: ... def __getitem__(self, project_name: str) -> list[Distribution]: ... - def __iter__(self) -> Iterator[str]: ... def add(self, dist: Distribution) -> None: ... - def remove(self, dist: Distribution) -> None: ... - def can_add(self, dist: Distribution) -> bool: ... - def __add__(self, other: Distribution | Environment) -> Environment: ... - def __iadd__(self, other: Distribution | Environment) -> Self: ... @overload def best_match( self, req: Requirement, working_set: WorkingSet, installer: None = None, replace_conflicting: bool = False @@ -79,7 +76,9 @@ class Environment: def obtain(self, requirement: Requirement, installer: None = None) -> None: ... @overload def obtain(self, requirement: Requirement, installer: Callable[[Requirement], _T]) -> _T: ... - def scan(self, search_path: Sequence[str] | None = None) -> None: ... + def __iter__(self) -> Iterator[str]: ... + def __iadd__(self, other: Distribution | Environment) -> Self: ... + def __add__(self, other: Distribution | Environment) -> Environment: ... def parse_requirements(strs: str | Iterable[str]) -> Generator[Requirement, None, None]: ... @@ -92,17 +91,17 @@ class Requirement(packaging_requirements.Requirement): extras: tuple[str, ...] # type: ignore[assignment] # incompatible override of attribute on base class specs: list[tuple[str, str]] def __init__(self, requirement_string: str) -> None: ... + def __eq__(self, other_requirement: object) -> bool: ... + def __contains__(self, item: Distribution | str | tuple[str, ...]) -> bool: ... @staticmethod def parse(s: str | Iterable[str]) -> Requirement: ... - def __contains__(self, item: Distribution | str | tuple[str, ...]) -> bool: ... - def __eq__(self, other_requirement: object) -> bool: ... def load_entry_point(dist: _EPDistType, group: str, name: str) -> Any: ... -def get_entry_info(dist: _EPDistType, group: str, name: str) -> EntryPoint | None: ... @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: pattern: ClassVar[Pattern[str]] @@ -119,6 +118,9 @@ class EntryPoint: extras: tuple[str, ...] = (), dist: Distribution | None = None, ) -> None: ... + def load(self, require: bool = True, env: Environment | None = ..., installer: _InstallerType | None = ...) -> Any: ... + def resolve(self) -> Any: ... + def require(self, env: Environment | None = None, installer: _InstallerType | None = None) -> None: ... @classmethod def parse(cls, src: str, dist: Distribution | None = None) -> EntryPoint: ... @classmethod @@ -127,9 +129,6 @@ class EntryPoint: def parse_map( cls, data: dict[str, str | Sequence[str]] | str | Sequence[str], dist: Distribution | None = None ) -> dict[str, EntryPoint]: ... - def load(self, require: bool = True, env: Environment | None = ..., installer: _InstallerType | None = ...) -> Any: ... - def require(self, env: Environment | None = None, installer: _InstallerType | None = None) -> None: ... - def resolve(self) -> Any: ... def find_distributions(path_item: str, only: bool = False) -> Generator[Distribution, None, None]: ... @overload @@ -143,28 +142,28 @@ SOURCE_DIST: int CHECKOUT_DIST: int DEVELOP_DIST: int -def resource_exists(package_or_requirement: _PkgReqType, resource_name: str) -> bool: ... -def resource_stream(package_or_requirement: _PkgReqType, resource_name: str) -> IO[bytes]: ... -def resource_string(package_or_requirement: _PkgReqType, resource_name: str) -> bytes: ... -def resource_isdir(package_or_requirement: _PkgReqType, resource_name: str) -> bool: ... -def resource_listdir(package_or_requirement: _PkgReqType, resource_name: str) -> list[str]: ... -def resource_filename(package_or_requirement: _PkgReqType, resource_name: str) -> str: ... -def set_extraction_path(path: str) -> None: ... -def cleanup_resources(force: bool = False) -> list[str]: ... @type_check_only class _IResourceManager(Protocol): 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_isdir(self, package_or_requirement: _PkgReqType, resource_name: str) -> bool: ... def resource_listdir(self, package_or_requirement: _PkgReqType, resource_name: str) -> list[str]: ... - def resource_filename(self, package_or_requirement: _PkgReqType, resource_name: str) -> str: ... - def set_extraction_path(self, path: str) -> None: ... - def cleanup_resources(self, force: bool = ...) -> list[str]: ... - def get_cache_path(self, archive_name: str, names: Iterable[str] = ...) -> str: ... def extraction_error(self) -> None: ... + def get_cache_path(self, archive_name: str, names: Iterable[str] = ...) -> str: ... def postprocess(self, tempname: str, filename: str) -> None: ... + def set_extraction_path(self, path: str) -> None: ... + def cleanup_resources(self, force: bool = ...) -> list[str]: ... +def resource_exists(package_or_requirement: _PkgReqType, resource_name: str) -> bool: ... +def resource_isdir(package_or_requirement: _PkgReqType, resource_name: str) -> bool: ... +def resource_filename(package_or_requirement: _PkgReqType, resource_name: str) -> str: ... +def resource_stream(package_or_requirement: _PkgReqType, resource_name: str) -> IO[bytes]: ... +def resource_string(package_or_requirement: _PkgReqType, resource_name: str) -> bytes: ... +def resource_listdir(package_or_requirement: _PkgReqType, resource_name: str) -> list[str]: ... +def set_extraction_path(path: str) -> None: ... +def cleanup_resources(force: bool = False) -> list[str]: ... @overload def get_provider(moduleOrReq: str) -> IResourceProvider: ... @overload @@ -248,27 +247,10 @@ class NullProvider: # Doesn't actually extend NullProvider class Distribution(NullProvider): PKG_INFO: ClassVar[str] - location: str project_name: str - @property - def hashcmp(self) -> tuple[Incomplete, int, str, Incomplete | 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 extras(self) -> list[str]: ... - @property - def version(self) -> str: ... - @property - def parsed_version(self) -> packaging_version.Version: ... py_version: str platform: str | None + location: str precedence: int def __init__( self, @@ -284,22 +266,39 @@ class Distribution(NullProvider): def from_location( cls, location: str, basename: str, metadata: _MetadataType = None, **kw: str | None | int ) -> Distribution: ... + @property + def hashcmp(self) -> tuple[Incomplete, int, str, Incomplete | 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: tuple[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 @classmethod def from_filename(cls, filename: str, metadata: _MetadataType = None, **kw: str | None | int) -> Distribution: ... - def activate(self, path: list[str] | None = None, replace: bool = False) -> None: ... def as_requirement(self) -> Requirement: ... - def requires(self, extras: tuple[str, ...] = ()) -> list[Requirement]: ... - def check_version_conflict(self) -> None: ... - def has_version(self) -> bool: ... - def clone(self, **kw: str | int | None) -> Requirement: ... - def egg_name(self) -> str: ... # type: ignore[override] # supertype's egg_name is a variable, not a method - def get_entry_info(self, group: str, name: str) -> EntryPoint | None: ... - def insert_on(self, path, loc: Incomplete | None = None, replace: bool = False) -> None: ... + def load_entry_point(self, group: str, name: str) -> Any: ... @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 load_entry_point(self, group: str, name: str) -> Any: ... + def get_entry_info(self, group: str, name: str) -> EntryPoint | None: ... + def insert_on(self, path, 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 | None) -> Requirement: ... + @property + def extras(self) -> list[str]: ... class DistInfoDistribution(Distribution): PKG_INFO: ClassVar[Literal["METADATA"]]