Skip to content

Commit

Permalink
Replace bare Any in setuptools (python#12406)
Browse files Browse the repository at this point in the history
  • Loading branch information
Avasam authored and max-muoto committed Sep 8, 2024
1 parent bc35dbc commit 1ca8237
Show file tree
Hide file tree
Showing 26 changed files with 125 additions and 112 deletions.
6 changes: 3 additions & 3 deletions stdlib/distutils/dist.pyi
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from _typeshed import Incomplete, StrOrBytesPath, StrPath, SupportsWrite
from collections.abc import Iterable, Mapping
from collections.abc import Iterable, MutableMapping
from distutils.cmd import Command
from re import Pattern
from typing import IO, Any, ClassVar, Literal, TypeVar, overload
from typing import IO, ClassVar, Literal, TypeVar, overload
from typing_extensions import TypeAlias

command_re: Pattern[str]
Expand Down Expand Up @@ -60,7 +60,7 @@ class DistributionMetadata:
class Distribution:
cmdclass: dict[str, type[Command]]
metadata: DistributionMetadata
def __init__(self, attrs: Mapping[str, Any] | None = None) -> None: ...
def __init__(self, attrs: MutableMapping[str, Incomplete] | None = None) -> None: ...
def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ...
def parse_config_files(self, filenames: Iterable[str] | None = None) -> None: ...
@overload
Expand Down
6 changes: 4 additions & 2 deletions stubs/setuptools/pkg_resources/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class WorkingSet:
fallback: bool = True,
) -> tuple[list[Distribution], dict[Distribution, Exception]]: ...
def require(self, *requirements: _NestedStr) -> Sequence[Distribution]: ...
def subscribe(self, callback: Callable[[Distribution], object], existing: bool = True) -> None: ...
def subscribe(self, callback: Callable[[Distribution], Unused], existing: bool = True) -> None: ...

class Environment:
def __init__(
Expand Down Expand Up @@ -254,7 +254,9 @@ class EntryPoint:
self, require: Literal[True] = True, env: Environment | None = None, installer: _InstallerType | None = None
) -> _ResolvedEntryPoint: ...
@overload
def load(self, require: Literal[False], *args: Any, **kwargs: Any) -> _ResolvedEntryPoint: ...
def load(
self, require: Literal[False], *args: Environment | _InstallerType | None, **kwargs: Environment | _InstallerType | None
) -> _ResolvedEntryPoint: ...
def resolve(self) -> _ResolvedEntryPoint: ...
def require(self, env: Environment | None = None, installer: _InstallerType | None = None) -> None: ...
pattern: ClassVar[Pattern[str]]
Expand Down
9 changes: 5 additions & 4 deletions stubs/setuptools/setuptools/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from _typeshed import StrPath
from _typeshed import Incomplete, StrPath
from abc import abstractmethod
from collections.abc import Iterable, Mapping, Sequence
from typing import Any
Expand Down Expand Up @@ -48,7 +48,7 @@ def setup(
distclass: type[Distribution] = ...,
script_name: str = ...,
script_args: list[str] = ...,
options: Mapping[str, Any] = ...,
options: Mapping[str, Incomplete] = ...,
license: str = ...,
keywords: list[str] | str = ...,
platforms: list[str] | str = ...,
Expand All @@ -59,7 +59,7 @@ def setup(
provides: list[str] = ...,
requires: list[str] = ...,
command_packages: list[str] = ...,
command_options: Mapping[str, Mapping[str, tuple[Any, Any]]] = ...,
command_options: Mapping[str, Mapping[str, tuple[Incomplete, Incomplete]]] = ...,
package_data: Mapping[str, list[str]] = ...,
include_package_data: bool = ...,
libraries: list[str] = ...,
Expand All @@ -68,12 +68,13 @@ def setup(
include_dirs: list[str] = ...,
password: str = ...,
fullname: str = ...,
**attrs: Any,
**attrs,
) -> Distribution: ...

class Command(_Command):
command_consumes_arguments: bool
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]
Expand Down
6 changes: 3 additions & 3 deletions stubs/setuptools/setuptools/_distutils/dist.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from _typeshed import Incomplete, StrOrBytesPath, StrPath, SupportsWrite
from collections.abc import Iterable, Mapping
from collections.abc import Iterable, MutableMapping
from re import Pattern
from typing import IO, Any, ClassVar, Literal, TypeVar, overload
from typing import IO, ClassVar, Literal, TypeVar, overload
from typing_extensions import TypeAlias

from .cmd import Command
Expand Down Expand Up @@ -61,7 +61,7 @@ class DistributionMetadata:
class Distribution:
cmdclass: dict[str, type[Command]]
metadata: DistributionMetadata
def __init__(self, attrs: Mapping[str, Any] | None = None) -> None: ...
def __init__(self, attrs: MutableMapping[str, Incomplete] | None = None) -> None: ...
def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ...
def parse_config_files(self, filenames: Iterable[str] | None = None) -> None: ...
@overload
Expand Down
4 changes: 2 additions & 2 deletions stubs/setuptools/setuptools/archive_util.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from _typeshed import Incomplete
from typing import Any
from collections.abc import Callable

from ._distutils.errors import DistutilsError

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

extraction_drivers: Any
extraction_drivers: tuple[Callable[..., Incomplete], ...]
17 changes: 8 additions & 9 deletions stubs/setuptools/setuptools/build_meta.pyi
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from _typeshed import StrPath
from _typeshed import Incomplete, StrPath
from collections.abc import Mapping
from typing import Any
from typing_extensions import TypeAlias

from . import dist
Expand All @@ -18,10 +17,10 @@ __all__ = [
"SetupRequirementsError",
]

_ConfigSettings: TypeAlias = dict[str, str | list[str] | None] | None
_ConfigSettings: TypeAlias = Mapping[str, str | list[str] | None] | None

class SetupRequirementsError(BaseException):
specifiers: Any
specifiers: Incomplete
def __init__(self, specifiers) -> None: ...

class Distribution(dist.Distribution):
Expand All @@ -31,10 +30,10 @@ 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: Mapping[str, Any] | None = None) -> list[str]: ...
def get_requires_for_build_sdist(self, config_settings: Mapping[str, Any] | None = None) -> list[str]: ...
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: Mapping[str, Any] | None = None
self, metadata_directory: str, config_settings: _ConfigSettings | None = None
) -> str: ...
def build_wheel(
self, wheel_directory: StrPath, config_settings: _ConfigSettings | None = None, metadata_directory: StrPath | None = None
Expand All @@ -43,9 +42,9 @@ class _BuildMetaBackend:
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: Mapping[str, Any] | None = None) -> list[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: Mapping[str, Any] | None = None
self, metadata_directory: str, config_settings: _ConfigSettings | None = None
) -> str: ...

class _BuildMetaLegacyBackend(_BuildMetaBackend):
Expand Down
7 changes: 4 additions & 3 deletions stubs/setuptools/setuptools/command/alias.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, ClassVar
from _typeshed import Incomplete
from typing import ClassVar

from .setopt import option_base

Expand All @@ -9,8 +10,8 @@ class alias(option_base):
command_consumes_arguments: bool
user_options: ClassVar[list[tuple[str, str, str]]]
boolean_options: ClassVar[list[str]]
args: Any
remove: Any
args: Incomplete
remove: Incomplete
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
def run(self) -> None: ...
Expand Down
6 changes: 3 additions & 3 deletions stubs/setuptools/setuptools/command/bdist_wheel.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from _typeshed import Incomplete
from _typeshed import Incomplete, Unused
from collections.abc import Callable, Iterable
from types import TracebackType
from typing import ClassVar, Final, Literal
Expand All @@ -19,9 +19,9 @@ def get_abi_tag() -> str | None: ...
def safer_name(name: str) -> str: ...
def safer_version(version: str) -> str: ...
def remove_readonly(
func: Callable[..., object], path: str, excinfo: tuple[type[Exception], Exception, TracebackType]
func: Callable[[str], Unused], path: str, excinfo: tuple[type[Exception], Exception, TracebackType]
) -> None: ...
def remove_readonly_exc(func: Callable[..., object], path: str, exc: Exception) -> None: ...
def remove_readonly_exc(func: Callable[[str], Unused], path: str, exc: Exception) -> None: ...

class bdist_wheel(Command):
description: ClassVar[str]
Expand Down
14 changes: 7 additions & 7 deletions stubs/setuptools/setuptools/command/build_ext.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from _typeshed import Incomplete
from typing import Any, ClassVar
from typing import ClassVar

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

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

class build_ext(_build_ext):
editable_mode: ClassVar[bool]
inplace: Any
inplace: bool
def run(self) -> None: ...
def copy_extensions_to_source(self) -> None: ...
def get_ext_filename(self, fullname): ...
shlib_compiler: Any
shlibs: Any
ext_map: Any
shlib_compiler: Incomplete
shlibs: list[Incomplete]
ext_map: dict[Incomplete, Incomplete]
def initialize_options(self) -> None: ...
extensions: Any
extensions: list[Incomplete]
def finalize_options(self) -> None: ...
def setup_shlib_compiler(self) -> None: ...
def get_export_symbols(self, ext): ...
compiler: Any
compiler: Incomplete
def build_extension(self, ext) -> None: ...
def links_to_dynamic(self, ext): ...
def get_outputs(self): ...
Expand Down
12 changes: 6 additions & 6 deletions stubs/setuptools/setuptools/command/build_py.pyi
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from _typeshed import Incomplete, StrPath
from typing import Any, ClassVar
from typing import ClassVar

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

class build_py(orig.build_py):
editable_mode: ClassVar[bool]
package_data: Any
exclude_package_data: Any
package_data: dict[str, list[str]]
exclude_package_data: dict[Incomplete, Incomplete]
def finalize_options(self) -> None: ...
def copy_file( # type: ignore[override]
self,
Expand All @@ -21,19 +21,19 @@ class build_py(orig.build_py):
level=1,
) -> tuple[_StrPathT | str, bool]: ...
def run(self) -> None: ...
data_files: Any
data_files: list[tuple[Incomplete, Incomplete, Incomplete, list[Incomplete]]]
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 get_outputs(self, include_bytecode: bool = True) -> list[str]: ... # type: ignore[override]
def build_package_data(self) -> None: ...
manifest_files: Any
manifest_files: dict[Incomplete, Incomplete]
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): ...
packages_checked: Any
packages_checked: dict[Incomplete, Incomplete]
def initialize_options(self) -> None: ...
def get_package_dir(self, package): ...
def exclude_data_files(self, package, src_dir, files): ...
Expand Down
19 changes: 11 additions & 8 deletions stubs/setuptools/setuptools/command/develop.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from typing import Any, ClassVar
from _typeshed import Incomplete
from typing import ClassVar

from pkg_resources import Distribution

from .. import namespaces
from .easy_install import easy_install
Expand All @@ -10,15 +13,15 @@ class develop(namespaces.DevelopInstaller, easy_install):
command_consumes_arguments: bool
multi_version: bool
def run(self) -> None: ... # type: ignore[override]
uninstall: Any
egg_path: Any
setup_path: Any
uninstall: Incomplete
egg_path: Incomplete
setup_path: Incomplete
always_copy_from: str
def initialize_options(self) -> None: ...
args: Any
egg_link: Any
egg_base: Any
dist: Any
args: list[Incomplete]
egg_link: str
egg_base: Incomplete
dist: Distribution
def finalize_options(self) -> None: ...
def install_for_development(self) -> None: ...
def uninstall_link(self) -> None: ...
Expand Down
3 changes: 1 addition & 2 deletions stubs/setuptools/setuptools/command/dist_info.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, ClassVar
from typing import ClassVar

from .._distutils.cmd import Command

Expand All @@ -7,7 +7,6 @@ class dist_info(Command):
user_options: ClassVar[list[tuple[str, str | None, str]]]
boolean_options: ClassVar[list[str]]
negative_opt: ClassVar[dict[str, str]]
egg_base: Any
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
def run(self) -> None: ...
7 changes: 4 additions & 3 deletions stubs/setuptools/setuptools/command/install.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from _typeshed import Incomplete
from collections.abc import Callable
from typing import Any, ClassVar

Expand All @@ -8,11 +9,11 @@ class install(orig.install):
boolean_options: ClassVar[list[str]]
# Any to work around variance issues
new_commands: list[tuple[str, Callable[[Any], bool]] | None]
old_and_unmanageable: Any
single_version_externally_managed: Any
old_and_unmanageable: Incomplete
single_version_externally_managed: Incomplete
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
path_file: Any
path_file: Incomplete
extra_dirs: str
def handle_extra_path(self): ...
def run(self): ...
Expand Down
11 changes: 6 additions & 5 deletions stubs/setuptools/setuptools/command/install_egg_info.pyi
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
from typing import Any, ClassVar
from _typeshed import Incomplete
from typing import ClassVar

from .. import Command, namespaces

class install_egg_info(namespaces.Installer, Command):
description: str
user_options: ClassVar[list[tuple[str, str, str]]]
install_dir: Any
install_dir: Incomplete
def initialize_options(self) -> None: ...
source: Any
target: Any
outputs: Any
source: Incomplete
target: str
outputs: list[Incomplete]
def finalize_options(self) -> None: ...
def run(self) -> None: ...
def get_outputs(self): ...
Expand Down
9 changes: 5 additions & 4 deletions stubs/setuptools/setuptools/command/rotate.pyi
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
from typing import Any, ClassVar
from _typeshed import Incomplete
from typing import ClassVar

from .. import Command

class rotate(Command):
description: str
user_options: ClassVar[list[tuple[str, str, str]]]
boolean_options: ClassVar[list[str]]
match: Any
dist_dir: Any
keep: Any
match: Incomplete
dist_dir: Incomplete
keep: Incomplete
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
def run(self) -> None: ...
5 changes: 3 additions & 2 deletions stubs/setuptools/setuptools/command/sdist.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, ClassVar
from _typeshed import Incomplete
from typing import ClassVar

from .._distutils.command import sdist as orig

Expand All @@ -9,7 +10,7 @@ class sdist(orig.sdist):
negative_opt: ClassVar[dict[str, str]]
README_EXTENSIONS: ClassVar[list[str]]
READMES: ClassVar[tuple[str, ...]]
filelist: Any
filelist: Incomplete
def run(self) -> None: ...
def initialize_options(self) -> None: ...
def make_distribution(self) -> None: ...
Expand Down
Loading

0 comments on commit 1ca8237

Please sign in to comment.