Skip to content

Commit 2aeb777

Browse files
authored
Replace bare Any in setuptools (#12406)
1 parent 421ac91 commit 2aeb777

26 files changed

+125
-112
lines changed

stdlib/distutils/dist.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from _typeshed import Incomplete, StrOrBytesPath, StrPath, SupportsWrite
2-
from collections.abc import Iterable, Mapping
2+
from collections.abc import Iterable, MutableMapping
33
from distutils.cmd import Command
44
from re import Pattern
5-
from typing import IO, Any, ClassVar, Literal, TypeVar, overload
5+
from typing import IO, ClassVar, Literal, TypeVar, overload
66
from typing_extensions import TypeAlias
77

88
command_re: Pattern[str]
@@ -60,7 +60,7 @@ class DistributionMetadata:
6060
class Distribution:
6161
cmdclass: dict[str, type[Command]]
6262
metadata: DistributionMetadata
63-
def __init__(self, attrs: Mapping[str, Any] | None = None) -> None: ...
63+
def __init__(self, attrs: MutableMapping[str, Incomplete] | None = None) -> None: ...
6464
def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ...
6565
def parse_config_files(self, filenames: Iterable[str] | None = None) -> None: ...
6666
@overload

stubs/setuptools/pkg_resources/__init__.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ class WorkingSet:
177177
fallback: bool = True,
178178
) -> tuple[list[Distribution], dict[Distribution, Exception]]: ...
179179
def require(self, *requirements: _NestedStr) -> Sequence[Distribution]: ...
180-
def subscribe(self, callback: Callable[[Distribution], object], existing: bool = True) -> None: ...
180+
def subscribe(self, callback: Callable[[Distribution], Unused], existing: bool = True) -> None: ...
181181

182182
class Environment:
183183
def __init__(
@@ -254,7 +254,9 @@ class EntryPoint:
254254
self, require: Literal[True] = True, env: Environment | None = None, installer: _InstallerType | None = None
255255
) -> _ResolvedEntryPoint: ...
256256
@overload
257-
def load(self, require: Literal[False], *args: Any, **kwargs: Any) -> _ResolvedEntryPoint: ...
257+
def load(
258+
self, require: Literal[False], *args: Environment | _InstallerType | None, **kwargs: Environment | _InstallerType | None
259+
) -> _ResolvedEntryPoint: ...
258260
def resolve(self) -> _ResolvedEntryPoint: ...
259261
def require(self, env: Environment | None = None, installer: _InstallerType | None = None) -> None: ...
260262
pattern: ClassVar[Pattern[str]]

stubs/setuptools/setuptools/__init__.pyi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from _typeshed import StrPath
1+
from _typeshed import Incomplete, StrPath
22
from abc import abstractmethod
33
from collections.abc import Iterable, Mapping, Sequence
44
from typing import Any
@@ -48,7 +48,7 @@ def setup(
4848
distclass: type[Distribution] = ...,
4949
script_name: str = ...,
5050
script_args: list[str] = ...,
51-
options: Mapping[str, Any] = ...,
51+
options: Mapping[str, Incomplete] = ...,
5252
license: str = ...,
5353
keywords: list[str] | str = ...,
5454
platforms: list[str] | str = ...,
@@ -59,7 +59,7 @@ def setup(
5959
provides: list[str] = ...,
6060
requires: list[str] = ...,
6161
command_packages: list[str] = ...,
62-
command_options: Mapping[str, Mapping[str, tuple[Any, Any]]] = ...,
62+
command_options: Mapping[str, Mapping[str, tuple[Incomplete, Incomplete]]] = ...,
6363
package_data: Mapping[str, list[str]] = ...,
6464
include_package_data: bool = ...,
6565
libraries: list[str] = ...,
@@ -68,12 +68,13 @@ def setup(
6868
include_dirs: list[str] = ...,
6969
password: str = ...,
7070
fullname: str = ...,
71-
**attrs: Any,
71+
**attrs,
7272
) -> Distribution: ...
7373

7474
class Command(_Command):
7575
command_consumes_arguments: bool
7676
distribution: Distribution
77+
# Any: Dynamic command subclass attributes
7778
def __init__(self, dist: Distribution, **kw: Any) -> None: ...
7879
def ensure_string_list(self, option: str | list[str]) -> None: ...
7980
def reinitialize_command(self, command: _Command | str, reinit_subcommands: bool = False, **kw: Any) -> _Command: ... # type: ignore[override]

stubs/setuptools/setuptools/_distutils/dist.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from _typeshed import Incomplete, StrOrBytesPath, StrPath, SupportsWrite
2-
from collections.abc import Iterable, Mapping
2+
from collections.abc import Iterable, MutableMapping
33
from re import Pattern
4-
from typing import IO, Any, ClassVar, Literal, TypeVar, overload
4+
from typing import IO, ClassVar, Literal, TypeVar, overload
55
from typing_extensions import TypeAlias
66

77
from .cmd import Command
@@ -61,7 +61,7 @@ class DistributionMetadata:
6161
class Distribution:
6262
cmdclass: dict[str, type[Command]]
6363
metadata: DistributionMetadata
64-
def __init__(self, attrs: Mapping[str, Any] | None = None) -> None: ...
64+
def __init__(self, attrs: MutableMapping[str, Incomplete] | None = None) -> None: ...
6565
def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ...
6666
def parse_config_files(self, filenames: Iterable[str] | None = None) -> None: ...
6767
@overload

stubs/setuptools/setuptools/archive_util.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from _typeshed import Incomplete
2-
from typing import Any
2+
from collections.abc import Callable
33

44
from ._distutils.errors import DistutilsError
55

@@ -21,4 +21,4 @@ def unpack_directory(filename, extract_dir, progress_filter=...) -> None: ...
2121
def unpack_zipfile(filename, extract_dir, progress_filter=...) -> None: ...
2222
def unpack_tarfile(filename, extract_dir, progress_filter=...): ...
2323

24-
extraction_drivers: Any
24+
extraction_drivers: tuple[Callable[..., Incomplete], ...]

stubs/setuptools/setuptools/build_meta.pyi

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
from _typeshed import StrPath
1+
from _typeshed import Incomplete, StrPath
22
from collections.abc import Mapping
3-
from typing import Any
43
from typing_extensions import TypeAlias
54

65
from . import dist
@@ -18,10 +17,10 @@ __all__ = [
1817
"SetupRequirementsError",
1918
]
2019

21-
_ConfigSettings: TypeAlias = dict[str, str | list[str] | None] | None
20+
_ConfigSettings: TypeAlias = Mapping[str, str | list[str] | None] | None
2221

2322
class SetupRequirementsError(BaseException):
24-
specifiers: Any
23+
specifiers: Incomplete
2524
def __init__(self, specifiers) -> None: ...
2625

2726
class Distribution(dist.Distribution):
@@ -31,10 +30,10 @@ class Distribution(dist.Distribution):
3130

3231
class _BuildMetaBackend:
3332
def run_setup(self, setup_script: str = "setup.py") -> None: ...
34-
def get_requires_for_build_wheel(self, config_settings: Mapping[str, Any] | None = None) -> list[str]: ...
35-
def get_requires_for_build_sdist(self, config_settings: Mapping[str, Any] | None = None) -> list[str]: ...
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]: ...
3635
def prepare_metadata_for_build_wheel(
37-
self, metadata_directory: str, config_settings: Mapping[str, Any] | None = None
36+
self, metadata_directory: str, config_settings: _ConfigSettings | None = None
3837
) -> str: ...
3938
def build_wheel(
4039
self, wheel_directory: StrPath, config_settings: _ConfigSettings | None = None, metadata_directory: StrPath | None = None
@@ -43,9 +42,9 @@ class _BuildMetaBackend:
4342
def build_editable(
4443
self, wheel_directory: StrPath, config_settings: _ConfigSettings | None = None, metadata_directory: str | None = None
4544
) -> str: ...
46-
def get_requires_for_build_editable(self, config_settings: Mapping[str, Any] | None = None) -> list[str]: ...
45+
def get_requires_for_build_editable(self, config_settings: _ConfigSettings | None = None) -> list[str]: ...
4746
def prepare_metadata_for_build_editable(
48-
self, metadata_directory: str, config_settings: Mapping[str, Any] | None = None
47+
self, metadata_directory: str, config_settings: _ConfigSettings | None = None
4948
) -> str: ...
5049

5150
class _BuildMetaLegacyBackend(_BuildMetaBackend):

stubs/setuptools/setuptools/command/alias.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, ClassVar
1+
from _typeshed import Incomplete
2+
from typing import ClassVar
23

34
from .setopt import option_base
45

@@ -9,8 +10,8 @@ class alias(option_base):
910
command_consumes_arguments: bool
1011
user_options: ClassVar[list[tuple[str, str, str]]]
1112
boolean_options: ClassVar[list[str]]
12-
args: Any
13-
remove: Any
13+
args: Incomplete
14+
remove: Incomplete
1415
def initialize_options(self) -> None: ...
1516
def finalize_options(self) -> None: ...
1617
def run(self) -> None: ...

stubs/setuptools/setuptools/command/bdist_wheel.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from _typeshed import Incomplete
1+
from _typeshed import Incomplete, Unused
22
from collections.abc import Callable, Iterable
33
from types import TracebackType
44
from typing import ClassVar, Final, Literal
@@ -19,9 +19,9 @@ def get_abi_tag() -> str | None: ...
1919
def safer_name(name: str) -> str: ...
2020
def safer_version(version: str) -> str: ...
2121
def remove_readonly(
22-
func: Callable[..., object], path: str, excinfo: tuple[type[Exception], Exception, TracebackType]
22+
func: Callable[[str], Unused], path: str, excinfo: tuple[type[Exception], Exception, TracebackType]
2323
) -> None: ...
24-
def remove_readonly_exc(func: Callable[..., object], path: str, exc: Exception) -> None: ...
24+
def remove_readonly_exc(func: Callable[[str], Unused], path: str, exc: Exception) -> None: ...
2525

2626
class bdist_wheel(Command):
2727
description: ClassVar[str]

stubs/setuptools/setuptools/command/build_ext.pyi

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from _typeshed import Incomplete
2-
from typing import Any, ClassVar
2+
from typing import ClassVar
33

44
from .._distutils.command.build_ext import build_ext as _build_ext
55

@@ -12,19 +12,19 @@ def get_abi3_suffix(): ...
1212

1313
class build_ext(_build_ext):
1414
editable_mode: ClassVar[bool]
15-
inplace: Any
15+
inplace: bool
1616
def run(self) -> None: ...
1717
def copy_extensions_to_source(self) -> None: ...
1818
def get_ext_filename(self, fullname): ...
19-
shlib_compiler: Any
20-
shlibs: Any
21-
ext_map: Any
19+
shlib_compiler: Incomplete
20+
shlibs: list[Incomplete]
21+
ext_map: dict[Incomplete, Incomplete]
2222
def initialize_options(self) -> None: ...
23-
extensions: Any
23+
extensions: list[Incomplete]
2424
def finalize_options(self) -> None: ...
2525
def setup_shlib_compiler(self) -> None: ...
2626
def get_export_symbols(self, ext): ...
27-
compiler: Any
27+
compiler: Incomplete
2828
def build_extension(self, ext) -> None: ...
2929
def links_to_dynamic(self, ext): ...
3030
def get_outputs(self): ...

stubs/setuptools/setuptools/command/build_py.pyi

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from _typeshed import Incomplete, StrPath
2-
from typing import Any, ClassVar
2+
from typing import ClassVar
33

44
from .._distutils.cmd import _StrPathT
55
from .._distutils.command import build_py as orig
@@ -8,8 +8,8 @@ def make_writable(target) -> None: ...
88

99
class build_py(orig.build_py):
1010
editable_mode: ClassVar[bool]
11-
package_data: Any
12-
exclude_package_data: Any
11+
package_data: dict[str, list[str]]
12+
exclude_package_data: dict[Incomplete, Incomplete]
1313
def finalize_options(self) -> None: ...
1414
def copy_file( # type: ignore[override]
1515
self,
@@ -21,19 +21,19 @@ class build_py(orig.build_py):
2121
level=1,
2222
) -> tuple[_StrPathT | str, bool]: ...
2323
def run(self) -> None: ...
24-
data_files: Any
24+
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): ...
2929
def get_outputs(self, include_bytecode: bool = True) -> list[str]: ... # type: ignore[override]
3030
def build_package_data(self) -> None: ...
31-
manifest_files: Any
31+
manifest_files: dict[Incomplete, Incomplete]
3232
def get_output_mapping(self) -> dict[str, str]: ...
3333
def analyze_manifest(self) -> None: ...
3434
def get_data_files(self) -> None: ...
3535
def check_package(self, package, package_dir): ...
36-
packages_checked: Any
36+
packages_checked: dict[Incomplete, Incomplete]
3737
def initialize_options(self) -> None: ...
3838
def get_package_dir(self, package): ...
3939
def exclude_data_files(self, package, src_dir, files): ...

stubs/setuptools/setuptools/command/develop.pyi

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
from typing import Any, ClassVar
1+
from _typeshed import Incomplete
2+
from typing import ClassVar
3+
4+
from pkg_resources import Distribution
25

36
from .. import namespaces
47
from .easy_install import easy_install
@@ -10,15 +13,15 @@ class develop(namespaces.DevelopInstaller, easy_install):
1013
command_consumes_arguments: bool
1114
multi_version: bool
1215
def run(self) -> None: ... # type: ignore[override]
13-
uninstall: Any
14-
egg_path: Any
15-
setup_path: Any
16+
uninstall: Incomplete
17+
egg_path: Incomplete
18+
setup_path: Incomplete
1619
always_copy_from: str
1720
def initialize_options(self) -> None: ...
18-
args: Any
19-
egg_link: Any
20-
egg_base: Any
21-
dist: Any
21+
args: list[Incomplete]
22+
egg_link: str
23+
egg_base: Incomplete
24+
dist: Distribution
2225
def finalize_options(self) -> None: ...
2326
def install_for_development(self) -> None: ...
2427
def uninstall_link(self) -> None: ...
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, ClassVar
1+
from typing import ClassVar
22

33
from .._distutils.cmd import Command
44

@@ -7,7 +7,6 @@ class dist_info(Command):
77
user_options: ClassVar[list[tuple[str, str | None, str]]]
88
boolean_options: ClassVar[list[str]]
99
negative_opt: ClassVar[dict[str, str]]
10-
egg_base: Any
1110
def initialize_options(self) -> None: ...
1211
def finalize_options(self) -> None: ...
1312
def run(self) -> None: ...

stubs/setuptools/setuptools/command/install.pyi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from _typeshed import Incomplete
12
from collections.abc import Callable
23
from typing import Any, ClassVar
34

@@ -8,11 +9,11 @@ class install(orig.install):
89
boolean_options: ClassVar[list[str]]
910
# Any to work around variance issues
1011
new_commands: list[tuple[str, Callable[[Any], bool]] | None]
11-
old_and_unmanageable: Any
12-
single_version_externally_managed: Any
12+
old_and_unmanageable: Incomplete
13+
single_version_externally_managed: Incomplete
1314
def initialize_options(self) -> None: ...
1415
def finalize_options(self) -> None: ...
15-
path_file: Any
16+
path_file: Incomplete
1617
extra_dirs: str
1718
def handle_extra_path(self): ...
1819
def run(self): ...

stubs/setuptools/setuptools/command/install_egg_info.pyi

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
from typing import Any, ClassVar
1+
from _typeshed import Incomplete
2+
from typing import ClassVar
23

34
from .. import Command, namespaces
45

56
class install_egg_info(namespaces.Installer, Command):
67
description: str
78
user_options: ClassVar[list[tuple[str, str, str]]]
8-
install_dir: Any
9+
install_dir: Incomplete
910
def initialize_options(self) -> None: ...
10-
source: Any
11-
target: Any
12-
outputs: Any
11+
source: Incomplete
12+
target: str
13+
outputs: list[Incomplete]
1314
def finalize_options(self) -> None: ...
1415
def run(self) -> None: ...
1516
def get_outputs(self): ...
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1-
from typing import Any, ClassVar
1+
from _typeshed import Incomplete
2+
from typing import ClassVar
23

34
from .. import Command
45

56
class rotate(Command):
67
description: str
78
user_options: ClassVar[list[tuple[str, str, str]]]
89
boolean_options: ClassVar[list[str]]
9-
match: Any
10-
dist_dir: Any
11-
keep: Any
10+
match: Incomplete
11+
dist_dir: Incomplete
12+
keep: Incomplete
1213
def initialize_options(self) -> None: ...
1314
def finalize_options(self) -> None: ...
1415
def run(self) -> None: ...

stubs/setuptools/setuptools/command/sdist.pyi

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Any, ClassVar
1+
from _typeshed import Incomplete
2+
from typing import ClassVar
23

34
from .._distutils.command import sdist as orig
45

@@ -9,7 +10,7 @@ class sdist(orig.sdist):
910
negative_opt: ClassVar[dict[str, str]]
1011
README_EXTENSIONS: ClassVar[list[str]]
1112
READMES: ClassVar[tuple[str, ...]]
12-
filelist: Any
13+
filelist: Incomplete
1314
def run(self) -> None: ...
1415
def initialize_options(self) -> None: ...
1516
def make_distribution(self) -> None: ...

0 commit comments

Comments
 (0)