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: don't ignore "missing symbol from stub" in stubtest #11494

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions stubs/setuptools/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,3 @@ setuptools._distutils.*
# Other vendored code
setuptools._vendor.*
pkg_resources._vendor.*
# Deprecated in favor of importlib.resources, importlib.metadata and their backports
# So like distutils, we only add what we need to reference.
pkg_resources.AvailableDistributions
pkg_resources.ResourceManager
pkg_resources.extern
28 changes: 16 additions & 12 deletions stubs/setuptools/pkg_resources/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from abc import ABCMeta
from collections.abc import Callable, Generator, Iterable, Iterator, Sequence
from io import BytesIO
from re import Pattern
from typing import IO, Any, ClassVar, Literal, Protocol, TypeVar, overload, type_check_only
from typing import IO, Any, ClassVar, Literal, Protocol, TypeVar, overload
from typing_extensions import Self, TypeAlias

from ._vendored_packaging import requirements as packaging_requirements, version as packaging_version
Expand Down Expand Up @@ -80,6 +80,8 @@ class Environment:
def __iadd__(self, other: Distribution | Environment) -> Self: ...
def __add__(self, other: Distribution | Environment) -> Environment: ...

AvailableDistributions = Environment

def parse_requirements(strs: str | Iterable[str]) -> Generator[Requirement, None, None]: ...

class RequirementParseError(packaging_requirements.InvalidRequirement): ...
Expand Down Expand Up @@ -142,19 +144,21 @@ SOURCE_DIST: int
CHECKOUT_DIST: int
DEVELOP_DIST: int

@type_check_only
class _IResourceManager(Protocol):
class ResourceManager:
extraction_path: Incomplete
cached_files: Incomplete
def __init__(self) -> None: ...
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) -> None: ...
def get_cache_path(self, archive_name: str, names: Iterable[str] = ...) -> str: ...
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 cleanup_resources(self, force: bool = False) -> list[str]: ...

def resource_exists(package_or_requirement: _PkgReqType, resource_name: str) -> bool: ...
def resource_isdir(package_or_requirement: _PkgReqType, resource_name: str) -> bool: ...
Expand Down Expand Up @@ -203,7 +207,7 @@ class ContextualVersionConflict(VersionConflict):
class UnknownExtra(ResolutionError): ...

class ExtractionError(Exception):
manager: _IResourceManager
manager: ResourceManager
cache_path: str
original_error: Exception

Expand All @@ -214,9 +218,9 @@ def register_loader_type(loader_type: type, provider_factory: Callable[[types.Mo
def register_namespace_handler(importer_type: type, namespace_handler: _NSHandlerType) -> None: ...

class IResourceProvider(IMetadataProvider, Protocol):
def get_resource_filename(self, manager: _IResourceManager, resource_name): ...
def get_resource_stream(self, manager: _IResourceManager, resource_name): ...
def get_resource_string(self, manager: _IResourceManager, resource_name): ...
def get_resource_filename(self, manager: ResourceManager, resource_name): ...
def get_resource_stream(self, manager: ResourceManager, resource_name): ...
def get_resource_string(self, manager: ResourceManager, resource_name): ...
def has_resource(self, resource_name): ...
def resource_isdir(self, resource_name): ...
def resource_listdir(self, resource_name): ...
Expand All @@ -231,9 +235,9 @@ class NullProvider:
module_path: str | None

def __init__(self, module) -> None: ...
def get_resource_filename(self, manager: _IResourceManager, resource_name) -> str: ...
def get_resource_stream(self, manager: _IResourceManager, resource_name) -> BytesIO: ...
def get_resource_string(self, manager: _IResourceManager, resource_name): ...
def get_resource_filename(self, manager: ResourceManager, resource_name) -> str: ...
def get_resource_stream(self, manager: ResourceManager, resource_name) -> BytesIO: ...
def get_resource_string(self, manager: ResourceManager, resource_name): ...
def has_resource(self, resource_name) -> bool: ...
def has_metadata(self, name: str) -> bool | None: ...
def get_metadata(self, name: str) -> str: ...
Expand Down
17 changes: 17 additions & 0 deletions stubs/setuptools/pkg_resources/extern/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from _typeshed import Incomplete
from collections.abc import Generator

class VendorImporter:
root_name: Incomplete
vendored_names: Incomplete
vendor_pkg: Incomplete
def __init__(self, root_name, vendored_names=(), vendor_pkg: Incomplete | None = None) -> None: ...
@property
def search_path(self) -> Generator[Incomplete, None, None]: ...
def load_module(self, fullname): ...
def create_module(self, spec): ...
def exec_module(self, module) -> None: ...
def find_spec(self, fullname, path: Incomplete | None = None, target: Incomplete | None = None): ...
def install(self) -> None: ...

names: Incomplete
Loading