-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Don't ignore missing stubs in setuptools #10058
Changes from 5 commits
ec253ca
b9495d8
e72ce69
f05d076
bdf18ca
4057ff6
d0485e8
6dfcf40
4e0db81
dc9ff1d
373dabb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Mock | ||
setuptools.msvc.winreg |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Mock | ||
setuptools.msvc.winreg |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
version = "67.6.*" | ||
|
||
[tool.stubtest] | ||
ignore_missing_stub = true | ||
# darwin is equivalent to linux for OS-specific methods | ||
platforms = ["linux", "win32"] |
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -6,7 +6,7 @@ from abc import ABCMeta | |||||||||||||||||||||||||
from collections.abc import Callable, Generator, Iterable, Sequence | ||||||||||||||||||||||||||
from io import BytesIO | ||||||||||||||||||||||||||
from re import Pattern | ||||||||||||||||||||||||||
from typing import IO, Any, ClassVar, TypeVar, overload | ||||||||||||||||||||||||||
from typing import IO, Any, ClassVar, Protocol, TypeVar, overload, type_check_only | ||||||||||||||||||||||||||
from typing_extensions import Literal, Self, TypeAlias | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
_Version: TypeAlias = Incomplete # from packaging.version | ||||||||||||||||||||||||||
|
@@ -21,8 +21,8 @@ _PkgReqType: TypeAlias = str | Requirement | |||||||||||||||||||||||||
_DistFinderType: TypeAlias = Callable[[_Importer, str, bool], Generator[Distribution, None, None]] | ||||||||||||||||||||||||||
_NSHandlerType: TypeAlias = Callable[[_Importer, str, str, types.ModuleType], str] | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
def declare_namespace(name: str) -> None: ... | ||||||||||||||||||||||||||
def fixup_namespace_packages(path_item: str) -> None: ... | ||||||||||||||||||||||||||
def declare_namespace(packageName: str) -> None: ... | ||||||||||||||||||||||||||
def fixup_namespace_packages(path_item: str, parent=None) -> None: ... | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
class WorkingSet: | ||||||||||||||||||||||||||
entries: list[str] | ||||||||||||||||||||||||||
|
@@ -35,18 +35,24 @@ class WorkingSet: | |||||||||||||||||||||||||
def __iter__(self) -> Generator[Distribution, None, None]: ... | ||||||||||||||||||||||||||
def find(self, req: Requirement) -> Distribution | None: ... | ||||||||||||||||||||||||||
def resolve( | ||||||||||||||||||||||||||
self, requirements: Iterable[Requirement], env: Environment | None = None, installer: _InstallerType | None = None | ||||||||||||||||||||||||||
self, | ||||||||||||||||||||||||||
requirements: Iterable[Requirement], | ||||||||||||||||||||||||||
env: Environment | None = None, | ||||||||||||||||||||||||||
installer: _InstallerType | None = None, | ||||||||||||||||||||||||||
replace_conflicting=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]) -> None: ... | ||||||||||||||||||||||||||
def subscribe(self, callback: Callable[[Distribution], object], existing=True) -> None: ... | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
def find_plugins( | ||||||||||||||||||||||||||
self, plugin_env: Environment, full_env: Environment | None = None, fallback: bool = True | ||||||||||||||||||||||||||
self, plugin_env: Environment, full_env: Environment | None = None, installer=None, fallback: bool = True | ||||||||||||||||||||||||||
) -> tuple[list[Distribution], dict[Distribution, Exception]]: ... | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
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 | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
|
@@ -62,13 +68,15 @@ class Environment: | |||||||||||||||||||||||||
def __add__(self, other: Distribution | Environment) -> Environment: ... | ||||||||||||||||||||||||||
def __iadd__(self, other: Distribution | Environment) -> Self: ... | ||||||||||||||||||||||||||
@overload | ||||||||||||||||||||||||||
def best_match(self, req: Requirement, working_set: WorkingSet, *, replace_conflicting: bool = False) -> Distribution: ... | ||||||||||||||||||||||||||
def best_match( | ||||||||||||||||||||||||||
self, req: Requirement, working_set: WorkingSet, installer: None = None, replace_conflicting: bool = False | ||||||||||||||||||||||||||
) -> Distribution: ... | ||||||||||||||||||||||||||
@overload | ||||||||||||||||||||||||||
def best_match( | ||||||||||||||||||||||||||
self, req: Requirement, working_set: WorkingSet, installer: Callable[[Requirement], _T], replace_conflicting: bool = False | ||||||||||||||||||||||||||
) -> _T: ... | ||||||||||||||||||||||||||
@overload | ||||||||||||||||||||||||||
def obtain(self, requirement: Requirement) -> None: ... | ||||||||||||||||||||||||||
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: ... | ||||||||||||||||||||||||||
|
@@ -89,6 +97,7 @@ class Requirement: | |||||||||||||||||||||||||
# TODO: change this to packaging.markers.Marker | None once we can import | ||||||||||||||||||||||||||
# packaging.markers | ||||||||||||||||||||||||||
marker: Incomplete | None | ||||||||||||||||||||||||||
def __init__(self, requirement_string) -> None: ... | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It'll be the same as https://github.com/pypa/packaging/blob/55584fb5ca327ba38b74ca5c668125caaebd9a5d/src/packaging/requirements.py#L33
Suggested change
|
||||||||||||||||||||||||||
@staticmethod | ||||||||||||||||||||||||||
def parse(s: str | Iterable[str]) -> Requirement: ... | ||||||||||||||||||||||||||
def __contains__(self, item: Distribution | str | tuple[str, ...]) -> bool: ... | ||||||||||||||||||||||||||
|
@@ -97,11 +106,12 @@ class Requirement: | |||||||||||||||||||||||||
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) -> dict[str, dict[str, EntryPoint]]: ... | ||||||||||||||||||||||||||
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]: ... | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
class EntryPoint: | ||||||||||||||||||||||||||
pattern: ClassVar[Pattern[str]] | ||||||||||||||||||||||||||
name: str | ||||||||||||||||||||||||||
module_name: str | ||||||||||||||||||||||||||
attrs: tuple[str, ...] | ||||||||||||||||||||||||||
|
@@ -133,11 +143,21 @@ def get_distribution(dist: _D) -> _D: ... | |||||||||||||||||||||||||
@overload | ||||||||||||||||||||||||||
def get_distribution(dist: _PkgReqType) -> Distribution: ... | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
class Distribution(NullProvider, IResourceProvider, IMetadataProvider): | ||||||||||||||||||||||||||
# 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) -> bool: ... | ||||||||||||||||||||||||||
def __le__(self, other) -> bool: ... | ||||||||||||||||||||||||||
def __gt__(self, other) -> bool: ... | ||||||||||||||||||||||||||
def __ge__(self, other) -> bool: ... | ||||||||||||||||||||||||||
def __eq__(self, other) -> bool: ... | ||||||||||||||||||||||||||
def __ne__(self, other) -> bool: ... | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
@property | ||||||||||||||||||||||||||
def key(self) -> str: ... | ||||||||||||||||||||||||||
@property | ||||||||||||||||||||||||||
def extras(self) -> list[str]: ... | ||||||||||||||||||||||||||
|
@@ -164,15 +184,17 @@ class Distribution(NullProvider, IResourceProvider, IMetadataProvider): | |||||||||||||||||||||||||
) -> Distribution: ... | ||||||||||||||||||||||||||
@classmethod | ||||||||||||||||||||||||||
def from_filename(cls, filename: str, metadata: _MetadataType = None, **kw: str | None | int) -> Distribution: ... | ||||||||||||||||||||||||||
def activate(self, path: list[str] | None = None) -> None: ... | ||||||||||||||||||||||||||
def activate(self, path: list[str] | None = None, replace=False) -> None: ... | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||
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 __cmp__(self, other: Any) -> bool: ... | ||||||||||||||||||||||||||
def get_entry_info(self, group: str, name: str) -> EntryPoint | None: ... | ||||||||||||||||||||||||||
def insert_on(self, path, loc: Incomplete | None = None, replace: bool = False) -> None: ... | ||||||||||||||||||||||||||
@overload | ||||||||||||||||||||||||||
def get_entry_map(self) -> dict[str, dict[str, EntryPoint]]: ... | ||||||||||||||||||||||||||
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: ... | ||||||||||||||||||||||||||
|
@@ -191,8 +213,8 @@ def resource_listdir(package_or_requirement: _PkgReqType, resource_name: 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]: ... | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
class IResourceManager: | ||||||||||||||||||||||||||
@type_check_only | ||||||||||||||||||||||||||
class IResourceManager(Protocol): | ||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this class doesn't exist at runtime, should it maybe be private?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't that what The source docstrings do call it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. True, mypy has been pretty slow to implement this feature :) Elsewhere in typeshed, though, we generally don't rely on a feature unless it's supported by all major type checkers. We use |
||||||||||||||||||||||||||
def resource_exists(self, package_or_requirement: _PkgReqType, resource_name: str) -> bool: ... | ||||||||||||||||||||||||||
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: ... | ||||||||||||||||||||||||||
|
@@ -206,11 +228,11 @@ class IResourceManager: | |||||||||||||||||||||||||
def postprocess(self, tempname: str, filename: str) -> None: ... | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
@overload | ||||||||||||||||||||||||||
def get_provider(package_or_requirement: str) -> IResourceProvider: ... | ||||||||||||||||||||||||||
def get_provider(moduleOrReq: str) -> IResourceProvider: ... | ||||||||||||||||||||||||||
@overload | ||||||||||||||||||||||||||
def get_provider(package_or_requirement: Requirement) -> Distribution: ... | ||||||||||||||||||||||||||
def get_provider(moduleOrReq: Requirement) -> Distribution: ... | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
class IMetadataProvider: | ||||||||||||||||||||||||||
class IMetadataProvider(Protocol): | ||||||||||||||||||||||||||
def has_metadata(self, name: str) -> bool | None: ... | ||||||||||||||||||||||||||
def metadata_isdir(self, name: str) -> bool: ... | ||||||||||||||||||||||||||
def metadata_listdir(self, name: str) -> list[str]: ... | ||||||||||||||||||||||||||
|
@@ -254,7 +276,16 @@ def register_finder(importer_type: type, distribution_finder: _DistFinderType) - | |||||||||||||||||||||||||
def register_loader_type(loader_type: type, provider_factory: Callable[[types.ModuleType], IResourceProvider]) -> None: ... | ||||||||||||||||||||||||||
def register_namespace_handler(importer_type: type, namespace_handler: _NSHandlerType) -> None: ... | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
class IResourceProvider(IMetadataProvider): ... | ||||||||||||||||||||||||||
class IResourceProvider(IMetadataProvider, Protocol): | ||||||||||||||||||||||||||
def get_resource_filename(self, manager, resource_name): ... | ||||||||||||||||||||||||||
def get_resource_stream(self, manager, resource_name): ... | ||||||||||||||||||||||||||
def get_resource_string(self, manager, resource_name): ... | ||||||||||||||||||||||||||
def has_resource(self, resource_name): ... | ||||||||||||||||||||||||||
def resource_isdir(self, resource_name): ... | ||||||||||||||||||||||||||
def resource_listdir(self, resource_name): ... | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
def invalid_marker(text) -> SyntaxError | Literal[False]: ... | ||||||||||||||||||||||||||
def evaluate_marker(text, extra: Incomplete | None = None): ... | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
class NullProvider: | ||||||||||||||||||||||||||
egg_name: str | None | ||||||||||||||||||||||||||
|
@@ -281,37 +312,41 @@ class EggProvider(NullProvider): | |||||||||||||||||||||||||
|
||||||||||||||||||||||||||
class DefaultProvider(EggProvider): ... | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
class PathMetadata(DefaultProvider, IResourceProvider): | ||||||||||||||||||||||||||
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 | ||||||||||||||||||||||||||
@property | ||||||||||||||||||||||||||
def zipinfo(self): ... | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
class EggMetadata(ZipProvider, IResourceProvider): | ||||||||||||||||||||||||||
class EggMetadata(ZipProvider): | ||||||||||||||||||||||||||
JelleZijlstra marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||||||||||||||
loader: zipimport.zipimporter | ||||||||||||||||||||||||||
module_path: str | ||||||||||||||||||||||||||
def __init__(self, zipimporter: zipimport.zipimporter) -> None: ... | ||||||||||||||||||||||||||
def __init__(self, importer: zipimport.zipimporter) -> None: ... | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
class EmptyProvider(NullProvider): | ||||||||||||||||||||||||||
module_path: None | ||||||||||||||||||||||||||
def __init__(self) -> None: ... | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
empty_provider: EmptyProvider | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
class FileMetadata(EmptyProvider, IResourceProvider): | ||||||||||||||||||||||||||
def __init__(self, path_to_pkg_info: str) -> None: ... | ||||||||||||||||||||||||||
class FileMetadata(EmptyProvider): | ||||||||||||||||||||||||||
def __init__(self, path: str) -> None: ... | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
class PEP440Warning(RuntimeWarning): ... | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
parse_version = _Version | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
def yield_lines(iterable: _NestedStr) -> Generator[str, None, None]: ... | ||||||||||||||||||||||||||
def split_sections(strs: _NestedStr) -> Generator[tuple[str | None, list[str]], None, None]: ... | ||||||||||||||||||||||||||
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_or_version: str) -> str: ... | ||||||||||||||||||||||||||
def to_filename(name: str) -> str: ... | ||||||||||||||||||||||||||
def get_build_platform() -> str: ... | ||||||||||||||||||||||||||
def get_platform() -> str: ... | ||||||||||||||||||||||||||
def get_supported_platform() -> str: ... | ||||||||||||||||||||||||||
|
@@ -320,3 +355,5 @@ def get_default_cache() -> str: ... | |||||||||||||||||||||||||
def get_importer(path_item: str) -> _Importer: ... | ||||||||||||||||||||||||||
def ensure_directory(path: str) -> None: ... | ||||||||||||||||||||||||||
def normalize_path(filename: str) -> str: ... | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
class PkgResourcesDeprecationWarning(Warning): ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.