Don't ignore missing stubs in setuptools (#10058)

This commit is contained in:
Avasam
2023-05-19 02:03:34 -04:00
committed by GitHub
parent 274f449edc
commit b5c9d8d677
41 changed files with 765 additions and 97 deletions

View File

@@ -1,27 +1,16 @@
pkg_resources.Distribution.__cmp__
pkg_resources.Distribution.activate
pkg_resources.Distribution.get_entry_map
pkg_resources.EggMetadata.__init__
pkg_resources.Environment.best_match
pkg_resources.Environment.obtain
pkg_resources.FileMetadata.__init__
# These are used like protocols, but forgot to specify "self" as the first method param
pkg_resources.IResourceProvider.get_resource_filename
pkg_resources.IResourceProvider.get_resource_stream
pkg_resources.IResourceProvider.get_resource_string
pkg_resources.IResourceProvider.has_resource
pkg_resources.IResourceProvider.resource_isdir
pkg_resources.IResourceProvider.resource_listdir
pkg_resources.IMetadataProvider.get_metadata
pkg_resources.IMetadataProvider.get_metadata_lines
pkg_resources.IMetadataProvider.has_metadata
pkg_resources.IMetadataProvider.metadata_isdir
pkg_resources.IMetadataProvider.metadata_listdir
pkg_resources.IMetadataProvider.run_script
pkg_resources.IResourceManager
pkg_resources.Requirement.__init__
pkg_resources.WorkingSet.find_plugins
pkg_resources.WorkingSet.resolve
pkg_resources.WorkingSet.subscribe
pkg_resources.declare_namespace
pkg_resources.fixup_namespace_packages
pkg_resources.get_entry_map
pkg_resources.get_provider
pkg_resources.split_sections
pkg_resources.to_filename
# Is always set in __init__
pkg_resources.PathMetadata.egg_info
@@ -53,16 +42,24 @@ setuptools._distutils.dist.Distribution.get_requires
setuptools._distutils.dist.Distribution.get_provides
setuptools._distutils.dist.Distribution.get_obsoletes
# Uncomment once ignore_missing_stub is turned off
# # Not supported by typeshed
# setuptools.py34compat
# Not supported by typeshed
setuptools.py34compat
setuptools.command.py36compat
# # Private modules
# setuptools.config._validate_pyproject.*
# setuptools.build_meta._BuildMetaBackend.*
# Private modules
setuptools.config._validate_pyproject.*
setuptools.command.build_py.build_py.existing_egg_info_dir
# # Vendored and modified version of stdlib's distutils. Basically implementation details
# setuptools._distutils.*
# # Other vendored code
# setuptools._vendor.*
# pkg_resources._vendor.*
# Loop variable leak
setuptools.sandbox.AbstractSandbox.name
# Vendored and modified version of stdlib's distutils. Basically implementation details
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

View File

@@ -0,0 +1,2 @@
# Mock
setuptools.msvc.winreg

View File

@@ -0,0 +1,2 @@
# Mock
setuptools.msvc.winreg

View File

@@ -0,0 +1,54 @@
from __future__ import annotations
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
# 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(_, _, _)
editable_strategy = _LinkTree(_, _, _, _)
editable_strategy = _TopLevelFinder(_, _)
# Not EditableStrategy due to incompatible __call__ method
editable_strategy = EnsurePackagesDiscovered(_) # type: ignore
editable_strategy = _EnsurePackagesDiscovered(_, _, _) # type: ignore

View File

@@ -2,4 +2,5 @@ version = "67.7.*"
partial_stub = true
[tool.stubtest]
ignore_missing_stub = true
# darwin is equivalent to linux for OS-specific methods
platforms = ["linux", "win32"]

View File

@@ -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: 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]) -> None: ...
def subscribe(self, callback: Callable[[Distribution], object], existing: bool = True) -> None: ...
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: ...
@@ -85,6 +93,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: str) -> None: ...
@staticmethod
def parse(s: str | Iterable[str]) -> Requirement: ...
def __contains__(self, item: Distribution | str | tuple[str, ...]) -> bool: ...
@@ -93,11 +102,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, ...]
@@ -143,8 +153,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):
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: ...
@@ -158,11 +168,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]: ...
@@ -196,7 +206,7 @@ class ContextualVersionConflict(VersionConflict):
class UnknownExtra(ResolutionError): ...
class ExtractionError(Exception):
manager: IResourceManager
manager: _IResourceManager
cache_path: str
original_error: Exception
@@ -206,7 +216,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: _IResourceManager, resource_name): ...
def get_resource_stream(self, manager: _IResourceManager, resource_name): ...
def get_resource_string(self, manager: _IResourceManager, 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
@@ -215,9 +234,9 @@ class NullProvider:
module_path: str | None
def __init__(self, module) -> None: ...
def get_resource_filename(self, manager, resource_name) -> str: ...
def get_resource_stream(self, manager, resource_name) -> BytesIO: ...
def get_resource_string(self, manager, resource_name): ...
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 has_resource(self, resource_name) -> bool: ...
def has_metadata(self, name: str) -> bool | None: ...
def get_metadata(self, name: str) -> str: ...
@@ -228,11 +247,21 @@ class NullProvider:
def metadata_listdir(self, name: str) -> list[str]: ...
def run_script(self, script_name: str, namespace: dict[str, Any]) -> None: ...
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: 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]: ...
@@ -259,15 +288,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: 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 __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: ...
@@ -281,7 +312,7 @@ 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: ...
@@ -289,11 +320,13 @@ class PathMetadata(DefaultProvider, IResourceProvider):
class ZipProvider(EggProvider):
eagers: list[str] | None
zip_pre: str
@property
def zipinfo(self): ...
class EggMetadata(ZipProvider, IResourceProvider):
class EggMetadata(ZipProvider):
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
@@ -301,17 +334,19 @@ class EmptyProvider(NullProvider):
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): ...

View File

@@ -2,24 +2,31 @@ from abc import abstractmethod
from collections.abc import Iterable, Mapping, Sequence
from typing import Any
from setuptools.depends import Require as Require
from setuptools.dist import Distribution as Distribution
from setuptools.extension import Extension as Extension
from setuptools.warnings import SetuptoolsDeprecationWarning as SetuptoolsDeprecationWarning
from ._distutils.cmd import Command as _Command
from .depends import Require as Require
from .discovery import _Path
from .dist import Distribution as Distribution
from .extension import Extension as Extension
from .warnings import SetuptoolsDeprecationWarning as SetuptoolsDeprecationWarning
__all__ = [
"setup",
"Distribution",
"Command",
"Extension",
"Require",
"SetuptoolsDeprecationWarning",
"find_packages",
"find_namespace_packages",
]
__version__: str
class PackageFinder:
@classmethod
def find(cls, where: str = ".", exclude: Iterable[str] = (), include: Iterable[str] = ("*",)) -> list[str]: ...
class PEP420PackageFinder(PackageFinder): ...
find_packages = PackageFinder.find
find_namespace_packages = PEP420PackageFinder.find
# Pytype fails with the following:
# find_packages = PackageFinder.find
# find_namespace_packages = PEP420PackageFinder.find
def find_packages(where: _Path = ".", exclude: Iterable[str] = (), include: Iterable[str] = ("*",)) -> list[str]: ...
def find_namespace_packages(where: _Path = ".", exclude: Iterable[str] = (), include: Iterable[str] = ("*",)) -> list[str]: ...
def setup(
*,
name: str = ...,

View File

@@ -0,0 +1,52 @@
from _typeshed import Incomplete
from ..cmd import Command
class bdist_rpm(Command):
description: str
user_options: Incomplete
boolean_options: Incomplete
negative_opt: Incomplete
bdist_base: Incomplete
rpm_base: Incomplete
dist_dir: Incomplete
python: Incomplete
fix_python: Incomplete
spec_only: Incomplete
binary_only: Incomplete
source_only: Incomplete
use_bzip2: Incomplete
distribution_name: Incomplete
group: Incomplete
release: Incomplete
serial: Incomplete
vendor: Incomplete
packager: Incomplete
doc_files: Incomplete
changelog: Incomplete
icon: Incomplete
prep_script: Incomplete
build_script: Incomplete
install_script: Incomplete
clean_script: Incomplete
verify_script: Incomplete
pre_install: Incomplete
post_install: Incomplete
pre_uninstall: Incomplete
post_uninstall: Incomplete
prep: Incomplete
provides: Incomplete
requires: Incomplete
conflicts: Incomplete
build_requires: Incomplete
obsoletes: Incomplete
keep_temp: int
use_rpm_opt_flags: int
rpm3_mode: int
no_autoreq: int
force_arch: Incomplete
quiet: int
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
def finalize_package_data(self) -> None: ...
def run(self) -> None: ...

View File

@@ -0,0 +1,30 @@
from _typeshed import Incomplete
from ..cmd import Command
def show_compilers() -> None: ...
class build(Command):
description: str
user_options: Incomplete
boolean_options: Incomplete
help_options: Incomplete
build_base: str
build_purelib: Incomplete
build_platlib: Incomplete
build_lib: Incomplete
build_temp: Incomplete
build_scripts: Incomplete
compiler: Incomplete
plat_name: Incomplete
debug: Incomplete
force: int
executable: Incomplete
parallel: Incomplete
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
def run(self) -> None: ...
def has_pure_modules(self): ...
def has_c_libraries(self): ...
def has_ext_modules(self): ...
def has_scripts(self): ...

View File

@@ -3,6 +3,16 @@ from typing import Any
from ._distutils.errors import DistutilsError
__all__ = [
"unpack_archive",
"unpack_zipfile",
"unpack_tarfile",
"default_filter",
"UnrecognizedFormat",
"extraction_drivers",
"unpack_directory",
]
class UnrecognizedFormat(DistutilsError): ...
def default_filter(src, dst): ...

View File

@@ -1,7 +1,20 @@
from collections.abc import Mapping
from typing import Any
from setuptools import dist
from . import dist
__all__ = [
"get_requires_for_build_sdist",
"get_requires_for_build_wheel",
"prepare_metadata_for_build_wheel",
"build_wheel",
"build_sdist",
"get_requires_for_build_editable",
"prepare_metadata_for_build_editable",
"build_editable",
"__legacy__",
"SetupRequirementsError",
]
class SetupRequirementsError(BaseException):
specifiers: Any
@@ -41,4 +54,8 @@ prepare_metadata_for_build_wheel = _BACKEND.prepare_metadata_for_build_wheel
build_wheel = _BACKEND.build_wheel
build_sdist = _BACKEND.build_sdist
get_requires_for_build_editable = _BACKEND.get_requires_for_build_editable
prepare_metadata_for_build_editable = _BACKEND.prepare_metadata_for_build_editable
build_editable = _BACKEND.build_editable
__legacy__: _BuildMetaLegacyBackend

View File

@@ -1,6 +1,6 @@
from typing import Any
from setuptools.command.setopt import option_base
from .setopt import option_base
def shquote(arg): ...

View File

@@ -0,0 +1,49 @@
from _typeshed import Incomplete
from collections.abc import Generator
from .. import Command
def strip_module(filename): ...
def sorted_walk(dir) -> Generator[Incomplete, None, None]: ...
def write_stub(resource, pyfile) -> None: ...
class bdist_egg(Command):
description: str
user_options: Incomplete
boolean_options: Incomplete
bdist_dir: Incomplete
plat_name: Incomplete
keep_temp: int
dist_dir: Incomplete
skip_build: int
egg_output: Incomplete
exclude_source_files: Incomplete
def initialize_options(self) -> None: ...
egg_info: Incomplete
def finalize_options(self) -> None: ...
def do_install_data(self) -> None: ...
def get_outputs(self): ...
def call_command(self, cmdname, **kw): ...
stubs: Incomplete
def run(self) -> None: ...
def zap_pyfiles(self) -> None: ...
def zip_safe(self): ...
def gen_header(self): ...
def copy_metadata_to(self, target_dir) -> None: ...
def get_ext_outputs(self): ...
NATIVE_EXTENSIONS: Incomplete
def walk_egg(egg_dir) -> Generator[Incomplete, None, None]: ...
def analyze_egg(egg_dir, stubs): ...
def write_safety_flag(egg_dir, safe) -> None: ...
safety_flags: Incomplete
def scan_module(egg_dir, base, name, stubs): ...
def iter_symbols(code) -> Generator[Incomplete, None, None]: ...
def can_scan(): ...
INSTALL_DIRECTORY_ATTRS: Incomplete
def make_zipfile(zip_filename, base_dir, verbose: int = 0, dry_run: int = 0, compress: bool = True, mode: str = "w"): ...

View File

@@ -0,0 +1,4 @@
from .._distutils.command import bdist_rpm as orig
class bdist_rpm(orig.bdist_rpm):
def run(self) -> None: ...

View File

@@ -0,0 +1,16 @@
from typing import Protocol
from .._distutils.command.build import build as _build
class build(_build):
def get_sub_commands(self): ...
class SubCommand(Protocol):
editable_mode: bool
build_lib: str
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
def run(self) -> None: ...
def get_source_files(self) -> list[str]: ...
def get_outputs(self) -> list[str]: ...
def get_output_mapping(self) -> dict[str, str]: ...

View File

@@ -1,5 +1,5 @@
from _typeshed import Incomplete
from typing import Any
from typing import Any, ClassVar
from .._distutils.command.build_ext import build_ext as _build_ext
@@ -11,6 +11,7 @@ def if_dl(s): ...
def get_abi3_suffix(): ...
class build_ext(_build_ext):
editable_mode: ClassVar[bool]
inplace: Any
def run(self) -> None: ...
def copy_extensions_to_source(self) -> None: ...
@@ -27,6 +28,7 @@ class build_ext(_build_ext):
def build_extension(self, ext) -> None: ...
def links_to_dynamic(self, ext): ...
def get_outputs(self): ...
def get_output_mapping(self) -> dict[str, str]: ...
def write_stub(self, output_dir, ext, compile: bool = False) -> None: ...
def link_shared_object(

View File

@@ -1,10 +1,12 @@
from typing import Any
from _typeshed import Incomplete
from typing import Any, ClassVar
from .._distutils.command import build_py as orig
def make_writable(target) -> None: ...
class build_py(orig.build_py):
editable_mode: ClassVar[bool]
package_data: Any
exclude_package_data: Any
def finalize_options(self) -> None: ...
@@ -12,9 +14,11 @@ class build_py(orig.build_py):
data_files: Any
def __getattr__(self, attr: str): ...
def build_module(self, module, module_file, package): ...
def get_data_files_without_manifest(self) -> list[tuple[Incomplete, Incomplete, Incomplete, list[Incomplete]]]: ...
def find_data_files(self, package, src_dir): ...
def build_package_data(self) -> None: ...
manifest_files: Any
def get_output_mapping(self) -> dict[str, str]: ...
def analyze_manifest(self) -> None: ...
def get_data_files(self) -> None: ...
def check_package(self, package, package_dir): ...

View File

@@ -1,7 +1,7 @@
from typing import Any
from setuptools import namespaces
from setuptools.command.easy_install import easy_install
from .. import namespaces
from .easy_install import easy_install
class develop(namespaces.DevelopInstaller, easy_install):
description: str

View File

@@ -1,10 +1,12 @@
from typing import Any
from typing import Any, ClassVar
from .._distutils.cmd import Command
class dist_info(Command):
description: str
user_options: Any
boolean_options: ClassVar[list[str]]
negative_opt: ClassVar[dict[str, str]]
egg_base: Any
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...

View File

@@ -3,7 +3,10 @@ from collections.abc import Iterator
from typing import Any
from pkg_resources import Environment
from setuptools import Command, SetuptoolsDeprecationWarning
from .. import Command, SetuptoolsDeprecationWarning
__all__ = ["easy_install", "PthDistributions", "extract_wininst_cfg", "get_exe_prefixes"]
class easy_install(Command):
description: str

View File

@@ -0,0 +1,84 @@
from _typeshed import Incomplete
from enum import Enum
from pathlib import Path
from types import TracebackType
from typing import Protocol
from typing_extensions import Self, TypeAlias
from .. import Command, errors, namespaces
from ..dist import Distribution
from ..warnings import SetuptoolsWarning
# Actually from wheel.wheelfile import WheelFile
_WheelFile: TypeAlias = Incomplete
_Path: TypeAlias = str | Path
class _EditableMode(Enum):
STRICT: str
LENIENT: str
COMPAT: str
@classmethod
def convert(cls, mode: str | None) -> _EditableMode: ...
class editable_wheel(Command):
description: str
user_options: Incomplete
dist_dir: Incomplete
dist_info_dir: Incomplete
project_dir: Incomplete
mode: Incomplete
def initialize_options(self) -> None: ...
package_dir: Incomplete
def finalize_options(self) -> None: ...
def run(self) -> None: ...
class EditableStrategy(Protocol):
def __call__(self, wheel: _WheelFile, files: list[str], mapping: dict[str, str]) -> None: ...
def __enter__(self): ...
def __exit__(
self, _exc_type: type[BaseException] | None, _exc_value: BaseException | None, _traceback: TracebackType | None
) -> None: ...
class _StaticPth:
dist: Incomplete
name: Incomplete
path_entries: Incomplete
def __init__(self, dist: Distribution, name: str, path_entries: list[Path]) -> None: ...
def __call__(self, wheel: _WheelFile, files: list[str], mapping: dict[str, str]): ...
def __enter__(self) -> Self: ...
def __exit__(
self, _exc_type: type[BaseException] | None, _exc_value: BaseException | None, _traceback: TracebackType | None
) -> None: ...
class _LinkTree(_StaticPth):
auxiliary_dir: Incomplete
build_lib: Incomplete
def __init__(self, dist: Distribution, name: str, auxiliary_dir: _Path, build_lib: _Path) -> None: ...
def __call__(self, wheel: _WheelFile, files: list[str], mapping: dict[str, str]): ...
def __enter__(self) -> Self: ...
def __exit__(
self, _exc_type: type[BaseException] | None, _exc_value: BaseException | None, _traceback: TracebackType | None
) -> None: ...
class _TopLevelFinder:
dist: Incomplete
name: Incomplete
def __init__(self, dist: Distribution, name: str) -> None: ...
def __call__(self, wheel: _WheelFile, files: list[str], mapping: dict[str, str]): ...
def __enter__(self) -> Self: ...
def __exit__(
self, _exc_type: type[BaseException] | None, _exc_value: BaseException | None, _traceback: TracebackType | None
) -> None: ...
class _NamespaceInstaller(namespaces.Installer):
distribution: Incomplete
src_root: Incomplete
installation_dir: Incomplete
editable_name: Incomplete
outputs: Incomplete
dry_run: bool
def __init__(self, distribution, installation_dir, editable_name, src_root) -> None: ...
class InformationOnly(SetuptoolsWarning): ...
class LinksNotSupported(errors.FileError): ...
class _DebuggingTips(SetuptoolsWarning): ...

View File

@@ -1,9 +1,11 @@
from typing import Any
from typing_extensions import Final
from setuptools import Command, SetuptoolsDeprecationWarning
from setuptools.command.sdist import sdist
from .. import Command, SetuptoolsDeprecationWarning
from .._distutils.filelist import FileList as _FileList
from .sdist import sdist
PY_MAJOR: Final[str]
def translate_pattern(glob): ...

View File

@@ -1,6 +1,6 @@
from typing import Any
from setuptools import Command, namespaces
from .. import Command, namespaces
class install_egg_info(namespaces.Installer, Command):
description: str

View File

@@ -1,6 +1,6 @@
from typing import Any
from setuptools import Command
from .. import Command
class rotate(Command):
description: str

View File

@@ -1,4 +1,4 @@
from setuptools.command.setopt import option_base
from .setopt import option_base
class saveopts(option_base):
description: str

View File

@@ -1,7 +1,9 @@
from abc import abstractmethod
from typing import Any
from setuptools import Command
from .. import Command
__all__ = ["config_file", "edit_config", "option_base", "setopt"]
def config_file(kind: str = "local"): ...
def edit_config(filename, settings, dry_run: bool = False) -> None: ...

View File

@@ -5,7 +5,7 @@ from typing import Any, Generic, TypeVar, overload
from typing_extensions import Self
from unittest import TestLoader, TestSuite
from setuptools import Command
from .. import Command
_T = TypeVar("_T")

View File

@@ -1,2 +0,0 @@
def read_configuration(filepath, find_others: bool = False, ignore_option_errors: bool = False): ...
def parse_configuration(distribution, command_options, ignore_option_errors: bool = False): ...

View File

@@ -0,0 +1,9 @@
from _typeshed import Incomplete
from collections.abc import Callable
from typing import TypeVar
Fn = TypeVar("Fn", bound=Callable[..., Incomplete]) # noqa: Y001 # Exists at runtime
__all__ = ("parse_configuration", "read_configuration")
def read_configuration(filepath, find_others: bool = False, ignore_option_errors: bool = False): ...
def parse_configuration(distribution, command_options, ignore_option_errors: bool = False): ...

View File

@@ -0,0 +1,53 @@
import os
from _typeshed import Incomplete
from collections.abc import Callable, Iterable, Iterator, Mapping
from importlib.machinery import ModuleSpec
from types import TracebackType
from typing import TypeVar
from typing_extensions import Self, TypeAlias
from ..dist import Distribution
chain_iter: Incomplete
_Path: TypeAlias = str | os.PathLike[Incomplete]
_K = TypeVar("_K")
_VCo = TypeVar("_VCo", covariant=True)
class StaticModule:
def __init__(self, name: str, spec: ModuleSpec) -> None: ...
def __getattr__(self, attr): ...
def glob_relative(patterns: Iterable[str], root_dir: _Path | None = None) -> list[str]: ...
def read_files(filepaths: str | bytes | Iterable[_Path], root_dir: Incomplete | None = None) -> str: ...
def read_attr(attr_desc: str, package_dir: Mapping[str, str] | None = None, root_dir: _Path | None = None): ...
def resolve_class(
qualified_class_name: str, package_dir: Mapping[str, str] | None = None, root_dir: _Path | None = None
) -> Callable[..., Incomplete]: ...
def cmdclass(
values: dict[str, str], package_dir: Mapping[str, str] | None = None, root_dir: _Path | None = None
) -> dict[str, Callable[..., Incomplete]]: ...
def find_packages(
*, namespaces: bool = True, fill_package_dir: dict[str, str] | None = None, root_dir: _Path | None = None, **kwargs
) -> list[str]: ...
def version(value: Callable[..., Incomplete] | Iterable[str | int] | str) -> str: ...
def canonic_package_data(package_data: dict[Incomplete, Incomplete]) -> dict[Incomplete, Incomplete]: ...
def canonic_data_files(
data_files: list[Incomplete] | dict[Incomplete, Incomplete], root_dir: _Path | None = None
) -> list[tuple[str, list[str]]]: ...
def entry_points(text: str, text_source: str = "entry-points") -> dict[str, dict[Incomplete, Incomplete]]: ...
class EnsurePackagesDiscovered:
def __init__(self, distribution: Distribution) -> None: ...
def __call__(self) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(
self, _exc_type: type[BaseException] | None, _exc_value: BaseException | None, _traceback: TracebackType | None
) -> None: ...
@property
def package_dir(self) -> Mapping[str, str]: ...
class LazyMappingProxy(Mapping[_K, _VCo]):
def __init__(self, obtain_mapping_value: Callable[[], Mapping[_K, _VCo]]) -> None: ...
def __getitem__(self, key: _K) -> _VCo: ...
def __len__(self) -> int: ...
def __iter__(self) -> Iterator[_K]: ...

View File

@@ -0,0 +1,52 @@
import os
from _typeshed import Incomplete
from types import TracebackType
from typing_extensions import Self, TypeAlias
from ..dist import Distribution
from ..warnings import SetuptoolsWarning
from . import expand
_Path: TypeAlias = str | os.PathLike[Incomplete]
def load_file(filepath: _Path) -> dict[Incomplete, Incomplete]: ...
def validate(config: dict[Incomplete, Incomplete], filepath: _Path) -> bool: ...
def apply_configuration(dist: Distribution, filepath: _Path, ignore_option_errors: bool = False) -> Distribution: ...
def read_configuration(
filepath: _Path, expand: bool = True, ignore_option_errors: bool = False, dist: Distribution | None = None
): ...
def expand_configuration(
config: dict[Incomplete, Incomplete],
root_dir: _Path | None = None,
ignore_option_errors: bool = False,
dist: Distribution | None = None,
) -> dict[Incomplete, Incomplete]: ...
class _ConfigExpander:
config: Incomplete
root_dir: Incomplete
project_cfg: Incomplete
dynamic: Incomplete
setuptools_cfg: Incomplete
dynamic_cfg: Incomplete
ignore_option_errors: Incomplete
def __init__(
self,
config: dict[Incomplete, Incomplete],
root_dir: _Path | None = None,
ignore_option_errors: bool = False,
dist: Distribution | None = None,
) -> None: ...
def expand(self): ...
class _EnsurePackagesDiscovered(expand.EnsurePackagesDiscovered):
def __init__(
self, distribution: Distribution, project_cfg: dict[Incomplete, Incomplete], setuptools_cfg: dict[Incomplete, Incomplete]
) -> None: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
): ...
class _BetaConfiguration(SetuptoolsWarning): ...
class _InvalidFile(SetuptoolsWarning): ...

View File

@@ -0,0 +1,83 @@
import os
from _typeshed import Incomplete
from typing import Generic, TypeVar
from typing_extensions import TypeAlias
from .._distutils.dist import DistributionMetadata
from ..dist import Distribution
from . import expand
_Path: TypeAlias = str | os.PathLike[Incomplete]
SingleCommandOptions: Incomplete
AllCommandOptions: Incomplete
Target = TypeVar("Target", bound=Distribution | DistributionMetadata) # noqa: Y001 # Exists at runtime
def read_configuration(
filepath: _Path, find_others: bool = False, ignore_option_errors: bool = False
) -> dict[Incomplete, Incomplete]: ...
def apply_configuration(dist: Distribution, filepath: _Path) -> Distribution: ...
def configuration_to_dict(
handlers: tuple[ConfigHandler[Distribution | DistributionMetadata], ...]
) -> dict[Incomplete, Incomplete]: ...
def parse_configuration(
distribution: Distribution, command_options: AllCommandOptions, ignore_option_errors: bool = False
) -> tuple[ConfigMetadataHandler, ConfigOptionsHandler]: ...
class ConfigHandler(Generic[Target]):
section_prefix: str
aliases: dict[str, str]
ignore_option_errors: Incomplete
target_obj: Incomplete
sections: Incomplete
set_options: Incomplete
ensure_discovered: Incomplete
def __init__(
self,
target_obj: Target,
options: AllCommandOptions,
ignore_option_errors,
ensure_discovered: expand.EnsurePackagesDiscovered,
) -> None: ...
@property
def parsers(self) -> None: ...
def __setitem__(self, option_name, value): ...
def parse_section(self, section_options) -> None: ...
def parse(self) -> None: ...
class ConfigMetadataHandler(ConfigHandler[DistributionMetadata]):
section_prefix: str
aliases: Incomplete
strict_mode: bool
package_dir: Incomplete
root_dir: Incomplete
def __init__(
self,
target_obj: DistributionMetadata,
options: AllCommandOptions,
ignore_option_errors: bool,
ensure_discovered: expand.EnsurePackagesDiscovered,
package_dir: dict[Incomplete, Incomplete] | None = None,
root_dir: _Path = ".",
) -> None: ...
@property
def parsers(self): ...
class ConfigOptionsHandler(ConfigHandler[Distribution]):
section_prefix: str
root_dir: Incomplete
package_dir: Incomplete
def __init__(
self,
target_obj: Distribution,
options: AllCommandOptions,
ignore_option_errors: bool,
ensure_discovered: expand.EnsurePackagesDiscovered,
) -> None: ...
@property
def parsers(self): ...
def parse_section_packages__find(self, section_options): ...
def parse_section_entry_points(self, section_options) -> None: ...
def parse_section_package_data(self, section_options) -> None: ...
def parse_section_exclude_package_data(self, section_options) -> None: ...
def parse_section_extras_require(self, section_options): ...
def parse_section_data_files(self, section_options) -> None: ...

View File

@@ -1,4 +1,12 @@
from _typeshed import Incomplete
from typing import IO, Any
from typing_extensions import Literal
__all__ = ["Require", "find_module", "get_module_constant", "extract_constant"]
def find_module(
module, paths=None
) -> tuple[IO[Any], str | None, tuple[str, Literal["", "r", "rb"], Literal[7, 6, 1, 2, 3, -1]]]: ...
class Require:
def __init__(

View File

@@ -0,0 +1,45 @@
import os
from _typeshed import Incomplete
from collections.abc import Iterable, Iterator, Mapping
from typing_extensions import TypeAlias
from . import Distribution
_Path: TypeAlias = str | os.PathLike[Incomplete]
StrIter: TypeAlias = Iterator[str]
chain_iter: Incomplete
class _Filter:
def __init__(self, *patterns: str) -> None: ...
def __call__(self, item: str) -> bool: ...
def __contains__(self, item: str) -> bool: ...
class _Finder:
ALWAYS_EXCLUDE: tuple[str, ...]
DEFAULT_EXCLUDE: tuple[str, ...]
@classmethod
def find(cls, where: _Path = ".", exclude: Iterable[str] = (), include: Iterable[str] = ("*",)) -> list[str]: ...
class PackageFinder(_Finder):
ALWAYS_EXCLUDE: Incomplete
class PEP420PackageFinder(PackageFinder): ...
class ModuleFinder(_Finder): ...
class FlatLayoutPackageFinder(PEP420PackageFinder):
DEFAULT_EXCLUDE: Incomplete
class FlatLayoutModuleFinder(ModuleFinder):
DEFAULT_EXCLUDE: Incomplete
class ConfigDiscovery:
dist: Incomplete
def __init__(self, distribution: Distribution) -> None: ...
def __call__(self, force: bool = False, name: bool = True, ignore_ext_modules: bool = False) -> None: ...
def analyse_name(self) -> None: ...
def remove_nested_packages(packages: list[str]) -> list[str]: ...
def remove_stubs(packages: list[str]) -> list[str]: ...
def find_parent_package(packages: list[str], package_dir: Mapping[str, str], root_dir: _Path) -> str | None: ...
def find_package_path(name: str, package_dir: Mapping[str, str], root_dir: _Path) -> str: ...
def construct_package_dir(packages: list[str], package_path: _Path) -> dict[str, str]: ...

View File

@@ -1,10 +1,11 @@
from collections.abc import Iterable, Iterator, Mapping, MutableMapping
from typing import Any
from setuptools import Command, SetuptoolsDeprecationWarning
from . import Command, SetuptoolsDeprecationWarning
from ._distutils.dist import Distribution as _Distribution
__all__ = ["Distribution"]
class Distribution(_Distribution):
def patch_missing_pkg_info(self, attrs: Mapping[str, Any]) -> None: ...
src_root: str | None

View File

@@ -1,3 +1,5 @@
__all__ = ["glob", "iglob", "escape"]
def glob(pathname, recursive: bool = False): ...
def iglob(pathname, recursive: bool = False): ...
def escape(pathname): ...

View File

@@ -0,0 +1,2 @@
def configure() -> None: ...
def set_threshold(level): ...

View File

@@ -4,6 +4,8 @@ from typing import Any
from pkg_resources import Environment
__all__ = ["PackageIndex", "distros_for_url", "parse_bdist_wininst", "interpret_distro_name"]
def parse_bdist_wininst(name): ...
def distros_for_url(url, metadata: Incomplete | None = None) -> None: ...
def interpret_distro_name(

View File

@@ -0,0 +1,3 @@
from _typeshed import Incomplete, StrOrBytesPath
def shutil_rmtree(path: StrOrBytesPath, ignore_errors: bool = False, onexc: Incomplete | None = None) -> None: ...

View File

@@ -1,15 +1,18 @@
import sys
from types import TracebackType
from typing import Any
from typing_extensions import Literal
from typing_extensions import Literal, Self
from ._distutils.errors import DistutilsError
__all__ = ["AbstractSandbox", "DirectorySandbox", "SandboxViolation", "run_setup"]
class UnpickleableException(Exception):
@staticmethod
def dump(type, exc): ...
class ExceptionSaver:
def __enter__(self): ...
def __enter__(self) -> Self: ...
def __exit__(
self, type: type[BaseException] | None, exc: BaseException | None, tb: TracebackType | None
) -> Literal[True] | None: ...
@@ -23,12 +26,40 @@ class AbstractSandbox:
self, exc_type: type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None
) -> None: ...
def run(self, func): ...
# Dynamically created
if sys.platform == "win32":
def startfile(self, path, *args, **kw): ...
else:
def chown(self, path, *args, **kw): ...
def chroot(self, path, *args, **kw): ...
def lchown(self, path, *args, **kw): ...
def mkfifo(self, path, *args, **kw): ...
def mknod(self, path, *args, **kw): ...
def pathconf(self, path, *args, **kw): ...
def access(self, path, *args, **kw): ...
def chdir(self, path, *args, **kw): ...
def chmod(self, path, *args, **kw): ...
def getcwd(self, *args, **kw): ...
def link(self, src, dst, *args, **kw): ...
def listdir(self, path, *args, **kw): ...
def lstat(self, path, *args, **kw): ...
def mkdir(self, path, *args, **kw): ...
def open(self, path, *args, **kw): ...
def readlink(self, path, *args, **kw): ...
def remove(self, path, *args, **kw): ...
def rename(self, src, dst, *args, **kw): ...
def rmdir(self, path, *args, **kw): ...
def stat(self, path, *args, **kw): ...
def symlink(self, src, dst, *args, **kw): ...
def unlink(self, path, *args, **kw): ...
def utime(self, path, *args, **kw): ...
class DirectorySandbox(AbstractSandbox):
write_ops: Any
def __init__(self, sandbox, exceptions=...) -> None: ...
def tmpnam(self) -> None: ...
def open(self, file, flags, mode: int = 511, *args, **kw): ...
def open(self, file, flags, mode: int = 511, *args, **kw): ... # type:ignore[override]
class SandboxViolation(DistutilsError):
tmpl: Any

View File

@@ -1,9 +1,11 @@
from collections.abc import Generator
from typing import Any
WHEEL_NAME: Any
NAMESPACE_PACKAGE_INIT: str
def unpack(src_dir, dst_dir) -> None: ...
def disable_info_traces() -> Generator[None, None, None]: ...
class Wheel:
filename: Any