Skip to content

Commit ac8720b

Browse files
authored
Setuptools stubs update from merging upstream (#12400)
1 parent 8fb8a4a commit ac8720b

22 files changed

+109
-90
lines changed

stdlib/distutils/cmd.pyi

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ from abc import abstractmethod
33
from collections.abc import Callable, Iterable
44
from distutils.dist import Distribution
55
from distutils.file_util import _BytesPathT, _StrPathT
6-
from typing import Any, ClassVar, Literal, overload
6+
from typing import Any, ClassVar, Literal, TypeVar, overload
77
from typing_extensions import TypeVarTuple, Unpack
88

9+
_CommandT = TypeVar("_CommandT", bound=Command)
910
_Ts = TypeVarTuple("_Ts")
1011

1112
class Command:
@@ -22,13 +23,16 @@ class Command:
2223
def announce(self, msg: str, level: int = 1) -> None: ...
2324
def debug_print(self, msg: str) -> None: ...
2425
def ensure_string(self, option: str, default: str | None = None) -> None: ...
25-
def ensure_string_list(self, option: str | list[str]) -> None: ...
26+
def ensure_string_list(self, option: str) -> None: ...
2627
def ensure_filename(self, option: str) -> None: ...
2728
def ensure_dirname(self, option: str) -> None: ...
2829
def get_command_name(self) -> str: ...
2930
def set_undefined_options(self, src_cmd: str, *option_pairs: tuple[str, str]) -> None: ...
3031
def get_finalized_command(self, command: str, create: bool | Literal[0, 1] = 1) -> Command: ...
31-
def reinitialize_command(self, command: Command | str, reinit_subcommands: bool | Literal[0, 1] = 0) -> Command: ...
32+
@overload
33+
def reinitialize_command(self, command: str, reinit_subcommands: bool | Literal[0, 1] = 0) -> Command: ...
34+
@overload
35+
def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool | Literal[0, 1] = 0) -> _CommandT: ...
3236
def run_command(self, command: str) -> None: ...
3337
def get_sub_commands(self) -> list[str]: ...
3438
def warn(self, msg: str) -> None: ...

stubs/setuptools/setuptools/__init__.pyi

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
from _typeshed import Incomplete, StrPath
22
from abc import abstractmethod
33
from collections.abc import Iterable, Mapping, Sequence
4-
from typing import Any
4+
from typing import Any, TypeVar, overload
55

66
from ._distutils.cmd import Command as _Command
77
from .depends import Require as Require
88
from .dist import Distribution as Distribution
99
from .extension import Extension as Extension
1010
from .warnings import SetuptoolsDeprecationWarning as SetuptoolsDeprecationWarning
1111

12+
_CommandT = TypeVar("_CommandT", bound=_Command)
13+
1214
__all__ = [
1315
"setup",
1416
"Distribution",
@@ -76,8 +78,11 @@ class Command(_Command):
7678
distribution: Distribution
7779
# Any: Dynamic command subclass attributes
7880
def __init__(self, dist: Distribution, **kw: Any) -> None: ...
79-
def ensure_string_list(self, option: str | list[str]) -> None: ...
80-
def reinitialize_command(self, command: _Command | str, reinit_subcommands: bool = False, **kw: Any) -> _Command: ... # type: ignore[override]
81+
def ensure_string_list(self, option: str) -> None: ...
82+
@overload # type: ignore[override] # Extra **kw param
83+
def reinitialize_command(self, command: str, reinit_subcommands: bool = False, **kw) -> _Command: ...
84+
@overload
85+
def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool = False, **kw) -> _CommandT: ...
8186
@abstractmethod
8287
def initialize_options(self) -> None: ...
8388
@abstractmethod

stubs/setuptools/setuptools/_distutils/cmd.pyi

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ from .dist import Distribution
88

99
_StrPathT = TypeVar("_StrPathT", bound=StrPath)
1010
_BytesPathT = TypeVar("_BytesPathT", bound=BytesPath)
11+
_CommandT = TypeVar("_CommandT", bound=Command)
1112
_Ts = TypeVarTuple("_Ts")
1213

1314
class Command:
@@ -25,13 +26,16 @@ class Command:
2526
def announce(self, msg: str, level: int = ...) -> None: ...
2627
def debug_print(self, msg: str) -> None: ...
2728
def ensure_string(self, option: str, default: str | None = ...) -> None: ...
28-
def ensure_string_list(self, option: str | list[str]) -> None: ...
29+
def ensure_string_list(self, option: str) -> None: ...
2930
def ensure_filename(self, option: str) -> None: ...
3031
def ensure_dirname(self, option: str) -> None: ...
3132
def get_command_name(self) -> str: ...
3233
def set_undefined_options(self, src_cmd: str, *option_pairs: tuple[str, str]) -> None: ...
3334
def get_finalized_command(self, command: str, create: bool = True) -> Command: ...
34-
def reinitialize_command(self, command: Command | str, reinit_subcommands: bool = False) -> Command: ...
35+
@overload
36+
def reinitialize_command(self, command: str, reinit_subcommands: bool = False) -> Command: ...
37+
@overload
38+
def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool = False) -> _CommandT: ...
3539
def run_command(self, command: str) -> None: ...
3640
def get_sub_commands(self) -> list[str]: ...
3741
def warn(self, msg: str) -> None: ...

stubs/setuptools/setuptools/_distutils/command/bdist.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class ListCompat(dict[str, tuple[str, str]]):
1313

1414
class bdist(Command):
1515
description: ClassVar[str]
16-
user_options: ClassVar[list[tuple[str | None, str | None, str | None]]]
16+
user_options: ClassVar[list[tuple[str, str | None, str | None]]]
1717
boolean_options: ClassVar[list[str]]
1818
help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], Unused]]]]
1919
no_format_option: ClassVar[tuple[str, ...]]

stubs/setuptools/setuptools/build_meta.pyi

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,18 @@ class Distribution(dist.Distribution):
3030

3131
class _BuildMetaBackend:
3232
def run_setup(self, setup_script: str = "setup.py") -> None: ...
33-
def get_requires_for_build_wheel(self, config_settings: _ConfigSettings | None = None) -> list[str]: ...
34-
def get_requires_for_build_sdist(self, config_settings: _ConfigSettings | None = None) -> list[str]: ...
35-
def prepare_metadata_for_build_wheel(
36-
self, metadata_directory: str, config_settings: _ConfigSettings | None = None
37-
) -> str: ...
33+
def get_requires_for_build_wheel(self, config_settings: _ConfigSettings = None) -> list[str]: ...
34+
def get_requires_for_build_sdist(self, config_settings: _ConfigSettings = None) -> list[str]: ...
35+
def prepare_metadata_for_build_wheel(self, metadata_directory: str, config_settings: _ConfigSettings = None) -> str: ...
3836
def build_wheel(
39-
self, wheel_directory: StrPath, config_settings: _ConfigSettings | None = None, metadata_directory: StrPath | None = None
37+
self, wheel_directory: StrPath, config_settings: _ConfigSettings = None, metadata_directory: StrPath | None = None
4038
) -> str: ...
41-
def build_sdist(self, sdist_directory: StrPath, config_settings: _ConfigSettings | None = None) -> str: ...
39+
def build_sdist(self, sdist_directory: StrPath, config_settings: _ConfigSettings = None) -> str: ...
4240
def build_editable(
43-
self, wheel_directory: StrPath, config_settings: _ConfigSettings | None = None, metadata_directory: str | None = None
44-
) -> str: ...
45-
def get_requires_for_build_editable(self, config_settings: _ConfigSettings | None = None) -> list[str]: ...
46-
def prepare_metadata_for_build_editable(
47-
self, metadata_directory: str, config_settings: _ConfigSettings | None = None
41+
self, wheel_directory: StrPath, config_settings: _ConfigSettings = None, metadata_directory: StrPath | None = None
4842
) -> str: ...
43+
def get_requires_for_build_editable(self, config_settings: _ConfigSettings = None) -> list[str]: ...
44+
def prepare_metadata_for_build_editable(self, metadata_directory: str, config_settings: _ConfigSettings = None) -> str: ...
4945

5046
class _BuildMetaLegacyBackend(_BuildMetaBackend):
5147
def run_setup(self, setup_script: str = "setup.py") -> None: ...

stubs/setuptools/setuptools/command/build_py.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ class build_py(orig.build_py):
1111
package_data: dict[str, list[str]]
1212
exclude_package_data: dict[Incomplete, Incomplete]
1313
def finalize_options(self) -> None: ...
14-
def copy_file( # type: ignore[override]
14+
def copy_file( # type: ignore[override] # No overload, str support only
1515
self,
1616
infile: StrPath,
1717
outfile: _StrPathT,
1818
preserve_mode: bool = True,
1919
preserve_times: bool = True,
2020
link: str | None = None,
21-
level=1,
21+
level: int = 1,
2222
) -> tuple[_StrPathT | str, bool]: ...
2323
def run(self) -> None: ...
2424
data_files: list[tuple[Incomplete, Incomplete, Incomplete, list[Incomplete]]]
2525
def __getattr__(self, attr: str): ...
2626
def build_module(self, module, module_file, package): ...
2727
def get_data_files_without_manifest(self) -> list[tuple[Incomplete, Incomplete, Incomplete, list[Incomplete]]]: ...
2828
def find_data_files(self, package, src_dir): ...
29-
def get_outputs(self, include_bytecode: bool = True) -> list[str]: ... # type: ignore[override]
29+
def get_outputs(self, include_bytecode: bool = True) -> list[str]: ... # type: ignore[override] # Using a real boolean instead of 0|1
3030
def build_package_data(self) -> None: ...
3131
manifest_files: dict[Incomplete, Incomplete]
3232
def get_output_mapping(self) -> dict[str, str]: ...

stubs/setuptools/setuptools/command/easy_install.pyi

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
from _typeshed import Incomplete
22
from collections.abc import Iterable, Iterator
3-
from typing import ClassVar, TypedDict
3+
from typing import Any, ClassVar, Literal, TypedDict, type_check_only
44
from typing_extensions import Self
55

66
from pkg_resources import Environment
7+
from setuptools.package_index import PackageIndex
78

89
from .. import Command, SetuptoolsDeprecationWarning
910

@@ -15,7 +16,7 @@ class easy_install(Command):
1516
user_options: ClassVar[list[tuple[str, str | None, str]]]
1617
boolean_options: ClassVar[list[str]]
1718
negative_opt: ClassVar[dict[str, str]]
18-
create_index: Incomplete
19+
create_index: ClassVar[type[PackageIndex]]
1920
user: bool
2021
zip_ok: Incomplete
2122
install_dir: Incomplete
@@ -36,22 +37,22 @@ class easy_install(Command):
3637
install_data: Incomplete
3738
install_base: Incomplete
3839
install_platbase: Incomplete
39-
install_userbase: Incomplete
40-
install_usersite: Incomplete
40+
install_userbase: str | None
41+
install_usersite: str | None
4142
no_find_links: Incomplete
4243
package_index: Incomplete
4344
pth_file: Incomplete
4445
site_dirs: Incomplete
4546
installed_projects: Incomplete
46-
verbose: Incomplete
47+
verbose: bool | Literal[0, 1]
4748
def initialize_options(self) -> None: ...
4849
def delete_blockers(self, blockers) -> None: ...
49-
config_vars: Incomplete
50+
config_vars: dict[str, Any]
5051
script_dir: Incomplete
51-
all_site_dirs: Incomplete
52-
shadow_path: Incomplete
53-
local_index: Incomplete
54-
outputs: Incomplete
52+
all_site_dirs: list[str]
53+
shadow_path: list[str]
54+
local_index: Environment
55+
outputs: list[Incomplete]
5556
def finalize_options(self) -> None: ...
5657
def expand_basedirs(self) -> None: ...
5758
def expand_dirs(self) -> None: ...
@@ -98,7 +99,7 @@ def get_exe_prefixes(exe_filename): ...
9899
class PthDistributions(Environment):
99100
dirty: bool
100101
filename: Incomplete
101-
sitedirs: Incomplete
102+
sitedirs: list[str]
102103
basedir: Incomplete
103104
paths: list[str]
104105
def __init__(self, filename, sitedirs=()) -> None: ...
@@ -108,9 +109,10 @@ class PthDistributions(Environment):
108109
def make_relative(self, path): ...
109110

110111
class RewritePthDistributions(PthDistributions):
111-
prelude: Incomplete
112-
postlude: Incomplete
112+
prelude: str
113+
postlude: str
113114

115+
@type_check_only
114116
class _SplitArgs(TypedDict, total=False):
115117
comments: bool
116118
posix: bool

stubs/setuptools/setuptools/command/editable_wheel.pyi

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from _typeshed import Incomplete, StrPath
2-
from collections.abc import Iterator
2+
from collections.abc import Iterator, Mapping
33
from enum import Enum
44
from pathlib import Path
55
from types import TracebackType
@@ -28,45 +28,45 @@ class editable_wheel(Command):
2828
project_dir: Incomplete
2929
mode: Incomplete
3030
def initialize_options(self) -> None: ...
31-
package_dir: Incomplete
31+
package_dir: dict[Incomplete, Incomplete]
3232
def finalize_options(self) -> None: ...
3333
def run(self) -> None: ...
3434

3535
class EditableStrategy(Protocol):
36-
def __call__(self, wheel: _WheelFile, files: list[str], mapping: dict[str, str]) -> None: ...
36+
def __call__(self, wheel: _WheelFile, files: list[str], mapping: Mapping[str, str]) -> None: ...
3737
def __enter__(self): ...
3838
def __exit__(
3939
self, _exc_type: type[BaseException] | None, _exc_value: BaseException | None, _traceback: TracebackType | None
4040
) -> None: ...
4141

4242
class _StaticPth:
43-
dist: Incomplete
44-
name: Incomplete
45-
path_entries: Incomplete
43+
dist: Distribution
44+
name: str
45+
path_entries: list[Path]
4646
def __init__(self, dist: Distribution, name: str, path_entries: list[Path]) -> None: ...
47-
def __call__(self, wheel: _WheelFile, files: list[str], mapping: dict[str, str]): ...
47+
def __call__(self, wheel: _WheelFile, files: list[str], mapping: Mapping[str, str]): ...
4848
def __enter__(self) -> Self: ...
4949
def __exit__(
5050
self, _exc_type: type[BaseException] | None, _exc_value: BaseException | None, _traceback: TracebackType | None
5151
) -> None: ...
5252

5353
class _LinkTree(_StaticPth):
54-
auxiliary_dir: Incomplete
55-
build_lib: Incomplete
54+
auxiliary_dir: Path
55+
build_lib: Path
5656
def __init__(self, dist: Distribution, name: str, auxiliary_dir: StrPath, build_lib: StrPath) -> None: ...
57-
def __call__(self, wheel: _WheelFile, files: list[str], mapping: dict[str, str]): ...
57+
def __call__(self, wheel: _WheelFile, files: list[str], mapping: Mapping[str, str]): ...
5858
def __enter__(self) -> Self: ...
5959
def __exit__(
6060
self, _exc_type: type[BaseException] | None, _exc_value: BaseException | None, _traceback: TracebackType | None
6161
) -> None: ...
6262

6363
class _TopLevelFinder:
64-
dist: Incomplete
65-
name: Incomplete
64+
dist: Distribution
65+
name: str
6666
def __init__(self, dist: Distribution, name: str) -> None: ...
6767
def template_vars(self) -> tuple[str, str, dict[str, str], dict[str, list[str]]]: ...
6868
def get_implementation(self) -> Iterator[tuple[str, bytes]]: ...
69-
def __call__(self, wheel: _WheelFile, files: list[str], mapping: dict[str, str]): ...
69+
def __call__(self, wheel: _WheelFile, files: list[str], mapping: Mapping[str, str]): ...
7070
def __enter__(self) -> Self: ...
7171
def __exit__(
7272
self, _exc_type: type[BaseException] | None, _exc_value: BaseException | None, _traceback: TracebackType | None
@@ -77,7 +77,7 @@ class _NamespaceInstaller(namespaces.Installer):
7777
src_root: Incomplete
7878
installation_dir: Incomplete
7979
editable_name: Incomplete
80-
outputs: Incomplete
80+
outputs: list[Incomplete]
8181
dry_run: bool
8282
def __init__(self, distribution, installation_dir, editable_name, src_root) -> None: ...
8383

stubs/setuptools/setuptools/command/egg_info.pyi

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class egg_info(InfoCommon, Command):
2828
egg_name: Incomplete
2929
egg_info: Incomplete
3030
egg_version: Incomplete
31-
broken_egg_info: bool
3231
def initialize_options(self) -> None: ...
3332
@property
3433
def tag_svn_revision(self) -> None: ...
@@ -65,7 +64,7 @@ class manifest_maker(sdist):
6564
force_manifest: bool
6665
def initialize_options(self) -> None: ...
6766
def finalize_options(self) -> None: ...
68-
filelist: Incomplete
67+
filelist: FileList
6968
def run(self) -> None: ...
7069
def write_manifest(self) -> None: ...
7170
def warn(self, msg) -> None: ...

stubs/setuptools/setuptools/command/install.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class install(orig.install):
1010
# Any to work around variance issues
1111
new_commands: list[tuple[str, Callable[[Any], bool]] | None]
1212
old_and_unmanageable: Incomplete
13-
single_version_externally_managed: Incomplete
13+
single_version_externally_managed: bool | None
1414
def initialize_options(self) -> None: ...
1515
def finalize_options(self) -> None: ...
1616
path_file: Incomplete

stubs/setuptools/setuptools/command/install_lib.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ class install_lib(orig.install_lib):
99
self,
1010
infile: StrPath,
1111
outfile: str,
12-
preserve_mode: bool = True, # type: ignore[override]
13-
preserve_times: bool = True, # type: ignore[override]
14-
preserve_symlinks: bool = False, # type: ignore[override]
12+
preserve_mode: bool = True,
13+
preserve_times: bool = True,
14+
preserve_symlinks: bool = False,
1515
level: Unused = 1,
1616
): ...
1717
def get_outputs(self): ...

stubs/setuptools/setuptools/command/upload_docs.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class upload_docs(upload):
88
DEFAULT_REPOSITORY: ClassVar[str]
99
description: ClassVar[str]
1010
user_options: ClassVar[list[tuple[str, str | None, str]]]
11-
boolean_options: ClassVar[list[str]]
11+
boolean_options = upload.boolean_options
1212
def has_sphinx(self): ...
1313
# Any to work around variance issues
1414
sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]]
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
1-
from _typeshed import Incomplete
1+
from _typeshed import Incomplete, StrPath
22
from collections.abc import Callable
33
from typing import TypeVar
44

5+
from setuptools.config.setupcfg import AllCommandOptions, ConfigMetadataHandler, ConfigOptionsHandler
6+
from setuptools.dist import Distribution
7+
58
Fn = TypeVar("Fn", bound=Callable[..., Incomplete]) # noqa: Y001 # Exists at runtime
69
__all__ = ("parse_configuration", "read_configuration")
710

8-
def read_configuration(filepath, find_others: bool = False, ignore_option_errors: bool = False): ...
9-
def parse_configuration(distribution, command_options, ignore_option_errors: bool = False): ...
11+
def read_configuration(
12+
filepath: StrPath, find_others: bool = False, ignore_option_errors: bool = False
13+
) -> dict[Incomplete, Incomplete]: ...
14+
def parse_configuration(
15+
distribution: Distribution, command_options: AllCommandOptions, ignore_option_errors: bool = False
16+
) -> tuple[ConfigMetadataHandler, ConfigOptionsHandler]: ...

stubs/setuptools/setuptools/config/expand.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ _VCo = TypeVar("_VCo", covariant=True)
1212

1313
class StaticModule:
1414
def __init__(self, name: str, spec: ModuleSpec) -> None: ...
15-
def __getattr__(self, attr): ...
15+
def __getattr__(self, attr: str): ...
1616

1717
def glob_relative(patterns: Iterable[str], root_dir: StrPath | None = None) -> list[str]: ...
1818
def read_files(filepaths: StrPath | Iterable[StrPath], root_dir: StrPath | None = None) -> str: ...

0 commit comments

Comments
 (0)