Setuptools stubs update from merging upstream (#12400)

This commit is contained in:
Avasam
2024-07-25 10:46:22 -04:00
committed by GitHub
parent 8fb8a4a489
commit ac8720b99d
22 changed files with 109 additions and 90 deletions

View File

@@ -1,7 +1,7 @@
from _typeshed import Incomplete, StrPath
from abc import abstractmethod
from collections.abc import Iterable, Mapping, Sequence
from typing import Any
from typing import Any, TypeVar, overload
from ._distutils.cmd import Command as _Command
from .depends import Require as Require
@@ -9,6 +9,8 @@ from .dist import Distribution as Distribution
from .extension import Extension as Extension
from .warnings import SetuptoolsDeprecationWarning as SetuptoolsDeprecationWarning
_CommandT = TypeVar("_CommandT", bound=_Command)
__all__ = [
"setup",
"Distribution",
@@ -76,8 +78,11 @@ class Command(_Command):
distribution: Distribution
# Any: Dynamic command subclass attributes
def __init__(self, dist: Distribution, **kw: Any) -> None: ...
def ensure_string_list(self, option: str | list[str]) -> None: ...
def reinitialize_command(self, command: _Command | str, reinit_subcommands: bool = False, **kw: Any) -> _Command: ... # type: ignore[override]
def ensure_string_list(self, option: str) -> None: ...
@overload # type: ignore[override] # Extra **kw param
def reinitialize_command(self, command: str, reinit_subcommands: bool = False, **kw) -> _Command: ...
@overload
def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool = False, **kw) -> _CommandT: ...
@abstractmethod
def initialize_options(self) -> None: ...
@abstractmethod

View File

@@ -8,6 +8,7 @@ from .dist import Distribution
_StrPathT = TypeVar("_StrPathT", bound=StrPath)
_BytesPathT = TypeVar("_BytesPathT", bound=BytesPath)
_CommandT = TypeVar("_CommandT", bound=Command)
_Ts = TypeVarTuple("_Ts")
class Command:
@@ -25,13 +26,16 @@ class Command:
def announce(self, msg: str, level: int = ...) -> None: ...
def debug_print(self, msg: str) -> None: ...
def ensure_string(self, option: str, default: str | None = ...) -> None: ...
def ensure_string_list(self, option: str | list[str]) -> None: ...
def ensure_string_list(self, option: str) -> None: ...
def ensure_filename(self, option: str) -> None: ...
def ensure_dirname(self, option: str) -> None: ...
def get_command_name(self) -> str: ...
def set_undefined_options(self, src_cmd: str, *option_pairs: tuple[str, str]) -> None: ...
def get_finalized_command(self, command: str, create: bool = True) -> Command: ...
def reinitialize_command(self, command: Command | str, reinit_subcommands: bool = False) -> Command: ...
@overload
def reinitialize_command(self, command: str, reinit_subcommands: bool = False) -> Command: ...
@overload
def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool = False) -> _CommandT: ...
def run_command(self, command: str) -> None: ...
def get_sub_commands(self) -> list[str]: ...
def warn(self, msg: str) -> None: ...

View File

@@ -13,7 +13,7 @@ class ListCompat(dict[str, tuple[str, str]]):
class bdist(Command):
description: ClassVar[str]
user_options: ClassVar[list[tuple[str | None, str | None, str | None]]]
user_options: ClassVar[list[tuple[str, str | None, str | None]]]
boolean_options: ClassVar[list[str]]
help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], Unused]]]]
no_format_option: ClassVar[tuple[str, ...]]

View File

@@ -30,22 +30,18 @@ class Distribution(dist.Distribution):
class _BuildMetaBackend:
def run_setup(self, setup_script: str = "setup.py") -> None: ...
def get_requires_for_build_wheel(self, config_settings: _ConfigSettings | None = None) -> list[str]: ...
def get_requires_for_build_sdist(self, config_settings: _ConfigSettings | None = None) -> list[str]: ...
def prepare_metadata_for_build_wheel(
self, metadata_directory: str, config_settings: _ConfigSettings | None = None
) -> str: ...
def get_requires_for_build_wheel(self, config_settings: _ConfigSettings = None) -> list[str]: ...
def get_requires_for_build_sdist(self, config_settings: _ConfigSettings = None) -> list[str]: ...
def prepare_metadata_for_build_wheel(self, metadata_directory: str, config_settings: _ConfigSettings = None) -> str: ...
def build_wheel(
self, wheel_directory: StrPath, config_settings: _ConfigSettings | None = None, metadata_directory: StrPath | None = None
self, wheel_directory: StrPath, config_settings: _ConfigSettings = None, metadata_directory: StrPath | None = None
) -> str: ...
def build_sdist(self, sdist_directory: StrPath, config_settings: _ConfigSettings | None = None) -> str: ...
def build_sdist(self, sdist_directory: StrPath, config_settings: _ConfigSettings = None) -> str: ...
def build_editable(
self, wheel_directory: StrPath, config_settings: _ConfigSettings | None = None, metadata_directory: str | None = None
) -> str: ...
def get_requires_for_build_editable(self, config_settings: _ConfigSettings | None = None) -> list[str]: ...
def prepare_metadata_for_build_editable(
self, metadata_directory: str, config_settings: _ConfigSettings | None = None
self, wheel_directory: StrPath, config_settings: _ConfigSettings = None, metadata_directory: StrPath | None = None
) -> str: ...
def get_requires_for_build_editable(self, config_settings: _ConfigSettings = None) -> list[str]: ...
def prepare_metadata_for_build_editable(self, metadata_directory: str, config_settings: _ConfigSettings = None) -> str: ...
class _BuildMetaLegacyBackend(_BuildMetaBackend):
def run_setup(self, setup_script: str = "setup.py") -> None: ...

View File

@@ -11,14 +11,14 @@ class build_py(orig.build_py):
package_data: dict[str, list[str]]
exclude_package_data: dict[Incomplete, Incomplete]
def finalize_options(self) -> None: ...
def copy_file( # type: ignore[override]
def copy_file( # type: ignore[override] # No overload, str support only
self,
infile: StrPath,
outfile: _StrPathT,
preserve_mode: bool = True,
preserve_times: bool = True,
link: str | None = None,
level=1,
level: int = 1,
) -> tuple[_StrPathT | str, bool]: ...
def run(self) -> None: ...
data_files: list[tuple[Incomplete, Incomplete, Incomplete, list[Incomplete]]]
@@ -26,7 +26,7 @@ class build_py(orig.build_py):
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 get_outputs(self, include_bytecode: bool = True) -> list[str]: ... # type: ignore[override]
def get_outputs(self, include_bytecode: bool = True) -> list[str]: ... # type: ignore[override] # Using a real boolean instead of 0|1
def build_package_data(self) -> None: ...
manifest_files: dict[Incomplete, Incomplete]
def get_output_mapping(self) -> dict[str, str]: ...

View File

@@ -1,9 +1,10 @@
from _typeshed import Incomplete
from collections.abc import Iterable, Iterator
from typing import ClassVar, TypedDict
from typing import Any, ClassVar, Literal, TypedDict, type_check_only
from typing_extensions import Self
from pkg_resources import Environment
from setuptools.package_index import PackageIndex
from .. import Command, SetuptoolsDeprecationWarning
@@ -15,7 +16,7 @@ class easy_install(Command):
user_options: ClassVar[list[tuple[str, str | None, str]]]
boolean_options: ClassVar[list[str]]
negative_opt: ClassVar[dict[str, str]]
create_index: Incomplete
create_index: ClassVar[type[PackageIndex]]
user: bool
zip_ok: Incomplete
install_dir: Incomplete
@@ -36,22 +37,22 @@ class easy_install(Command):
install_data: Incomplete
install_base: Incomplete
install_platbase: Incomplete
install_userbase: Incomplete
install_usersite: Incomplete
install_userbase: str | None
install_usersite: str | None
no_find_links: Incomplete
package_index: Incomplete
pth_file: Incomplete
site_dirs: Incomplete
installed_projects: Incomplete
verbose: Incomplete
verbose: bool | Literal[0, 1]
def initialize_options(self) -> None: ...
def delete_blockers(self, blockers) -> None: ...
config_vars: Incomplete
config_vars: dict[str, Any]
script_dir: Incomplete
all_site_dirs: Incomplete
shadow_path: Incomplete
local_index: Incomplete
outputs: Incomplete
all_site_dirs: list[str]
shadow_path: list[str]
local_index: Environment
outputs: list[Incomplete]
def finalize_options(self) -> None: ...
def expand_basedirs(self) -> None: ...
def expand_dirs(self) -> None: ...
@@ -98,7 +99,7 @@ def get_exe_prefixes(exe_filename): ...
class PthDistributions(Environment):
dirty: bool
filename: Incomplete
sitedirs: Incomplete
sitedirs: list[str]
basedir: Incomplete
paths: list[str]
def __init__(self, filename, sitedirs=()) -> None: ...
@@ -108,9 +109,10 @@ class PthDistributions(Environment):
def make_relative(self, path): ...
class RewritePthDistributions(PthDistributions):
prelude: Incomplete
postlude: Incomplete
prelude: str
postlude: str
@type_check_only
class _SplitArgs(TypedDict, total=False):
comments: bool
posix: bool

View File

@@ -1,5 +1,5 @@
from _typeshed import Incomplete, StrPath
from collections.abc import Iterator
from collections.abc import Iterator, Mapping
from enum import Enum
from pathlib import Path
from types import TracebackType
@@ -28,45 +28,45 @@ class editable_wheel(Command):
project_dir: Incomplete
mode: Incomplete
def initialize_options(self) -> None: ...
package_dir: Incomplete
package_dir: dict[Incomplete, 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 __call__(self, wheel: _WheelFile, files: list[str], mapping: Mapping[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
dist: Distribution
name: str
path_entries: list[Path]
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 __call__(self, wheel: _WheelFile, files: list[str], mapping: Mapping[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
auxiliary_dir: Path
build_lib: Path
def __init__(self, dist: Distribution, name: str, auxiliary_dir: StrPath, build_lib: StrPath) -> None: ...
def __call__(self, wheel: _WheelFile, files: list[str], mapping: dict[str, str]): ...
def __call__(self, wheel: _WheelFile, files: list[str], mapping: Mapping[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
dist: Distribution
name: str
def __init__(self, dist: Distribution, name: str) -> None: ...
def template_vars(self) -> tuple[str, str, dict[str, str], dict[str, list[str]]]: ...
def get_implementation(self) -> Iterator[tuple[str, bytes]]: ...
def __call__(self, wheel: _WheelFile, files: list[str], mapping: dict[str, str]): ...
def __call__(self, wheel: _WheelFile, files: list[str], mapping: Mapping[str, str]): ...
def __enter__(self) -> Self: ...
def __exit__(
self, _exc_type: type[BaseException] | None, _exc_value: BaseException | None, _traceback: TracebackType | None
@@ -77,7 +77,7 @@ class _NamespaceInstaller(namespaces.Installer):
src_root: Incomplete
installation_dir: Incomplete
editable_name: Incomplete
outputs: Incomplete
outputs: list[Incomplete]
dry_run: bool
def __init__(self, distribution, installation_dir, editable_name, src_root) -> None: ...

View File

@@ -28,7 +28,6 @@ class egg_info(InfoCommon, Command):
egg_name: Incomplete
egg_info: Incomplete
egg_version: Incomplete
broken_egg_info: bool
def initialize_options(self) -> None: ...
@property
def tag_svn_revision(self) -> None: ...
@@ -65,7 +64,7 @@ class manifest_maker(sdist):
force_manifest: bool
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
filelist: Incomplete
filelist: FileList
def run(self) -> None: ...
def write_manifest(self) -> None: ...
def warn(self, msg) -> None: ...

View File

@@ -10,7 +10,7 @@ class install(orig.install):
# Any to work around variance issues
new_commands: list[tuple[str, Callable[[Any], bool]] | None]
old_and_unmanageable: Incomplete
single_version_externally_managed: Incomplete
single_version_externally_managed: bool | None
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
path_file: Incomplete

View File

@@ -9,9 +9,9 @@ class install_lib(orig.install_lib):
self,
infile: StrPath,
outfile: str,
preserve_mode: bool = True, # type: ignore[override]
preserve_times: bool = True, # type: ignore[override]
preserve_symlinks: bool = False, # type: ignore[override]
preserve_mode: bool = True,
preserve_times: bool = True,
preserve_symlinks: bool = False,
level: Unused = 1,
): ...
def get_outputs(self): ...

View File

@@ -8,7 +8,7 @@ class upload_docs(upload):
DEFAULT_REPOSITORY: ClassVar[str]
description: ClassVar[str]
user_options: ClassVar[list[tuple[str, str | None, str]]]
boolean_options: ClassVar[list[str]]
boolean_options = upload.boolean_options
def has_sphinx(self): ...
# Any to work around variance issues
sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]]

View File

@@ -1,9 +1,16 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, StrPath
from collections.abc import Callable
from typing import TypeVar
from setuptools.config.setupcfg import AllCommandOptions, ConfigMetadataHandler, ConfigOptionsHandler
from setuptools.dist import Distribution
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): ...
def read_configuration(
filepath: StrPath, find_others: bool = False, ignore_option_errors: bool = False
) -> dict[Incomplete, Incomplete]: ...
def parse_configuration(
distribution: Distribution, command_options: AllCommandOptions, ignore_option_errors: bool = False
) -> tuple[ConfigMetadataHandler, ConfigOptionsHandler]: ...

View File

@@ -12,7 +12,7 @@ _VCo = TypeVar("_VCo", covariant=True)
class StaticModule:
def __init__(self, name: str, spec: ModuleSpec) -> None: ...
def __getattr__(self, attr): ...
def __getattr__(self, attr: str): ...
def glob_relative(patterns: Iterable[str], root_dir: StrPath | None = None) -> list[str]: ...
def read_files(filepaths: StrPath | Iterable[StrPath], root_dir: StrPath | None = None) -> str: ...

View File

@@ -1,5 +1,6 @@
from _typeshed import Incomplete, StrPath
from types import TracebackType
from typing import Any
from typing_extensions import Self
from ..dist import Distribution
@@ -11,7 +12,7 @@ def validate(config: dict[Incomplete, Incomplete], filepath: StrPath) -> bool: .
def apply_configuration(dist: Distribution, filepath: StrPath, ignore_option_errors: bool = False) -> Distribution: ...
def read_configuration(
filepath: StrPath, expand: bool = True, ignore_option_errors: bool = False, dist: Distribution | None = None
): ...
) -> dict[str, Any]: ...
def expand_configuration(
config: dict[Incomplete, Incomplete],
root_dir: StrPath | None = None,
@@ -20,13 +21,13 @@ def expand_configuration(
) -> dict[Incomplete, Incomplete]: ...
class _ConfigExpander:
config: Incomplete
root_dir: Incomplete
config: dict[Incomplete, Incomplete]
root_dir: StrPath
project_cfg: Incomplete
dynamic: Incomplete
setuptools_cfg: Incomplete
dynamic_cfg: Incomplete
ignore_option_errors: Incomplete
ignore_option_errors: bool
def __init__(
self,
config: dict[Incomplete, Incomplete],

View File

@@ -1,12 +1,13 @@
from _typeshed import Incomplete, StrPath
from typing import ClassVar, Generic, TypeVar
from typing import Any, ClassVar, Generic, TypeVar
from typing_extensions import TypeAlias
from .._distutils.dist import DistributionMetadata
from ..dist import Distribution
from . import expand
SingleCommandOptions: Incomplete
AllCommandOptions: Incomplete
SingleCommandOptions: TypeAlias = dict[str, tuple[str, Any]]
AllCommandOptions: TypeAlias = dict[str, SingleCommandOptions]
Target = TypeVar("Target", bound=Distribution | DistributionMetadata) # noqa: Y001 # Exists at runtime
def read_configuration(
@@ -24,10 +25,10 @@ class ConfigHandler(Generic[Target]):
section_prefix: str
aliases: ClassVar[dict[str, str]]
ignore_option_errors: Incomplete
target_obj: Incomplete
sections: Incomplete
set_options: Incomplete
ensure_discovered: Incomplete
target_obj: Target
sections: dict[str, SingleCommandOptions]
set_options: list[str]
ensure_discovered: expand.EnsurePackagesDiscovered
def __init__(
self,
target_obj: Target,
@@ -45,8 +46,8 @@ class ConfigMetadataHandler(ConfigHandler[DistributionMetadata]):
section_prefix: str
aliases: ClassVar[dict[str, str]]
strict_mode: bool
package_dir: Incomplete
root_dir: Incomplete
package_dir: dict[Incomplete, Incomplete] | None
root_dir: StrPath
def __init__(
self,
target_obj: DistributionMetadata,
@@ -61,8 +62,8 @@ class ConfigMetadataHandler(ConfigHandler[DistributionMetadata]):
class ConfigOptionsHandler(ConfigHandler[Distribution]):
section_prefix: str
root_dir: Incomplete
package_dir: Incomplete
root_dir: str | None
package_dir: dict[str, str]
def __init__(
self,
target_obj: Distribution,

View File

@@ -23,5 +23,5 @@ class Require:
def is_present(self, paths: Incomplete | None = None): ...
def is_current(self, paths: Incomplete | None = None): ...
def get_module_constant(module, symbol, default: int = -1, paths: Incomplete | None = None): ...
def extract_constant(code, symbol, default: int = -1): ...
def get_module_constant(module, symbol, default: str | int = -1, paths: Incomplete | None = None) -> Any: ...
def extract_constant(code, symbol, default: str | int = -1) -> Any: ...

View File

@@ -1,3 +1,4 @@
import itertools
from _typeshed import Incomplete, StrPath
from collections.abc import Iterable, Iterator, Mapping
from typing import ClassVar
@@ -6,7 +7,7 @@ from typing_extensions import TypeAlias
from . import Distribution
StrIter: TypeAlias = Iterator[str]
chain_iter: Incomplete
chain_iter = itertools.chain.from_iterable
class _Filter:
def __init__(self, *patterns: str) -> None: ...

View File

@@ -1,4 +1,4 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, StrPath
from collections.abc import Iterable, Iterator, MutableMapping
from . import Command, SetuptoolsDeprecationWarning
@@ -13,7 +13,7 @@ class Distribution(_Distribution):
def __init__(self, attrs: MutableMapping[str, Incomplete] | None = None) -> None: ...
def warn_dash_deprecation(self, opt: str, section: str) -> str: ...
def make_option_lowercase(self, opt: str, section: str) -> str: ...
def parse_config_files(self, filenames: Iterable[str] | None = None, ignore_option_errors: bool = False) -> None: ...
def parse_config_files(self, filenames: Iterable[StrPath] | None = None, ignore_option_errors: bool = False) -> None: ...
def fetch_build_eggs(self, requires: str | Iterable[str]): ...
def get_egg_cache_dir(self) -> str: ...
def fetch_build_egg(self, req): ...

View File

@@ -1,8 +1,3 @@
from ._distutils._modified import (
newer as newer,
newer_group as newer_group,
newer_pairwise as newer_pairwise,
newer_pairwise_group as newer_pairwise_group,
)
from ._distutils._modified import newer, newer_group, newer_pairwise, newer_pairwise_group
__all__ = ["newer", "newer_pairwise", "newer_group", "newer_pairwise_group"]

View File

@@ -93,7 +93,7 @@ class EnvironmentInfo:
pi: Incomplete
ri: Incomplete
si: Incomplete
def __init__(self, arch, vc_ver: Incomplete | None = None, vc_min_ver: int = 0) -> None: ...
def __init__(self, arch, vc_ver: Incomplete | None = None, vc_min_ver: float = 0) -> None: ...
@property
def vs_ver(self): ...
@property

View File

@@ -1,10 +1,14 @@
from typing_extensions import TypeAlias
_DueDate: TypeAlias = tuple[int, int, int] # time tuple
class SetuptoolsWarning(UserWarning):
@classmethod
def emit(
cls,
summary: str | None = None,
details: str | None = None,
due_date: tuple[int, int, int] | None = None,
due_date: _DueDate | None = None,
see_docs: str | None = None,
see_url: str | None = None,
stacklevel: int = 2,