Replace bare Any in setuptools (#12406)

This commit is contained in:
Avasam
2024-07-25 07:38:07 -04:00
committed by GitHub
parent 421ac91a30
commit 2aeb777cde
26 changed files with 125 additions and 112 deletions

View File

@@ -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]
@@ -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

View File

@@ -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__(
@@ -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]]

View File

@@ -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
@@ -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 = ...,
@@ -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] = ...,
@@ -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]

View File

@@ -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
@@ -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

View File

@@ -1,5 +1,5 @@
from _typeshed import Incomplete
from typing import Any
from collections.abc import Callable
from ._distutils.errors import DistutilsError
@@ -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], ...]

View File

@@ -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
@@ -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):
@@ -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
@@ -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):

View File

@@ -1,4 +1,5 @@
from typing import Any, ClassVar
from _typeshed import Incomplete
from typing import ClassVar
from .setopt import option_base
@@ -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: ...

View File

@@ -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
@@ -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]

View File

@@ -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
@@ -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): ...

View File

@@ -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
@@ -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,
@@ -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): ...

View File

@@ -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
@@ -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: ...

View File

@@ -1,4 +1,4 @@
from typing import Any, ClassVar
from typing import ClassVar
from .._distutils.cmd import Command
@@ -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: ...

View File

@@ -1,3 +1,4 @@
from _typeshed import Incomplete
from collections.abc import Callable
from typing import Any, ClassVar
@@ -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): ...

View File

@@ -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): ...

View File

@@ -1,4 +1,5 @@
from typing import Any, ClassVar
from _typeshed import Incomplete
from typing import ClassVar
from .. import Command
@@ -6,9 +7,9 @@ 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: ...

View File

@@ -1,4 +1,5 @@
from typing import Any, ClassVar
from _typeshed import Incomplete
from typing import ClassVar
from .._distutils.command import sdist as orig
@@ -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: ...

View File

@@ -1,5 +1,6 @@
from _typeshed import Incomplete
from abc import abstractmethod
from typing import Any, ClassVar
from typing import ClassVar
from .. import Command
@@ -11,9 +12,9 @@ def edit_config(filename, settings, dry_run: bool = False) -> None: ...
class option_base(Command):
user_options: ClassVar[list[tuple[str, str, str]]]
boolean_options: ClassVar[list[str]]
global_config: Any
user_config: Any
filename: Any
global_config: Incomplete
user_config: Incomplete
filename: Incomplete
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
@abstractmethod
@@ -23,10 +24,10 @@ class setopt(option_base):
description: str
user_options: ClassVar[list[tuple[str, str, str]]]
boolean_options: ClassVar[list[str]]
command: Any
option: Any
set_value: Any
remove: Any
command: Incomplete
option: Incomplete
set_value: Incomplete
remove: Incomplete
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
def run(self) -> None: ...

View File

@@ -1,33 +1,34 @@
from _typeshed import Incomplete, Unused
from collections.abc import Callable
from types import ModuleType
from typing import Any, ClassVar, Generic, TypeVar, overload
from typing import ClassVar, Generic, TypeVar, overload
from typing_extensions import Self
from unittest import TestLoader, TestSuite
from .. import Command
_T = TypeVar("_T")
_R = TypeVar("_R")
class ScanningLoader(TestLoader):
def __init__(self) -> None: ...
def loadTestsFromModule(self, module: ModuleType, pattern: Incomplete | None = None) -> list[TestSuite]: ... # type: ignore[override]
class NonDataProperty(Generic[_T]):
fget: Callable[..., _T]
def __init__(self, fget: Callable[..., _T]) -> None: ...
class NonDataProperty(Generic[_T, _R]):
fget: Callable[[_T], _R]
def __init__(self, fget: Callable[[_T], _R]) -> None: ...
@overload
def __get__(self, obj: None, objtype: Unused = None) -> Self: ...
@overload
def __get__(self, obj: Any, objtype: Unused = None) -> _T: ...
def __get__(self, obj: _T, objtype: Unused = None) -> _R: ...
class test(Command):
description: str
user_options: ClassVar[list[tuple[str, str, str]]]
test_suite: Any
test_module: Any
test_loader: Any
test_runner: Any
test_suite: Incomplete
test_module: Incomplete
test_loader: Incomplete
test_runner: Incomplete
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
@NonDataProperty

View File

@@ -1,3 +1,4 @@
from _typeshed import Incomplete
from collections.abc import Callable
from typing import Any, ClassVar
@@ -11,8 +12,8 @@ class upload_docs(upload):
def has_sphinx(self): ...
# Any to work around variance issues
sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]]
upload_dir: Any
target_dir: Any
upload_dir: Incomplete
target_dir: Incomplete
def initialize_options(self) -> None: ...
def finalize_options(self) -> None: ...
def create_zipfile(self, filename) -> None: ...

View File

@@ -26,7 +26,7 @@ def cmdclass(
def find_packages(
*, namespaces: bool = True, fill_package_dir: dict[str, str] | None = None, root_dir: StrPath | None = None, **kwargs
) -> list[str]: ...
def version(value: Callable[..., Incomplete] | Iterable[str | int] | str) -> 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: StrPath | None = None

View File

@@ -1,5 +1,5 @@
from _typeshed import Incomplete
from collections.abc import Iterable, Iterator, MutableMapping
from typing import Any
from . import Command, SetuptoolsDeprecationWarning
from ._distutils.dist import Distribution as _Distribution
@@ -10,7 +10,7 @@ class Distribution(_Distribution):
src_root: str | None
dependency_links: list[str]
setup_requires: list[str]
def __init__(self, attrs: MutableMapping[str, Any] | None = None) -> None: ...
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: ...

View File

@@ -1,8 +1,6 @@
from typing import Any
from ._distutils.extension import Extension as _Extension
have_pyrex: Any
def have_pyrex() -> bool: ...
class Extension(_Extension):
py_limited_api: bool

View File

@@ -1,6 +1,6 @@
from typing import Any
import itertools
flatten: Any
flatten = itertools.chain.from_iterable
class Installer:
nspkg_ext: str

View File

@@ -1,6 +1,9 @@
import configparser
import urllib.request
from _typeshed import Incomplete
from typing import Any
from hashlib import _Hash
from re import Pattern
from typing import ClassVar
from pkg_resources import Environment
@@ -18,10 +21,10 @@ class ContentChecker:
def report(self, reporter, template) -> None: ...
class HashChecker(ContentChecker):
pattern: Any
hash_name: Any
hash: Any
expected: Any
pattern: ClassVar[Pattern[str]]
hash_name: Incomplete
hash: _Hash
expected: Incomplete
def __init__(self, hash_name, expected) -> None: ...
@classmethod
def from_url(cls, url): ...
@@ -30,13 +33,13 @@ class HashChecker(ContentChecker):
def report(self, reporter, template): ...
class PackageIndex(Environment):
index_url: Any
scanned_urls: Any
fetched_urls: Any
package_pages: Any
allows: Any
to_scan: Any
opener: Any
index_url: str
scanned_urls: dict[Incomplete, Incomplete]
fetched_urls: dict[Incomplete, Incomplete]
package_pages: dict[Incomplete, Incomplete]
allows: Incomplete
to_scan: list[Incomplete]
opener = urllib.request.urlopen
def __init__(
self,
index_url: str = "https://pypi.org/simple/",
@@ -81,8 +84,8 @@ class PackageIndex(Environment):
def warn(self, msg, *args) -> None: ...
class Credential:
username: Any
password: Any
username: Incomplete
password: Incomplete
def __init__(self, username, password) -> None: ...
def __iter__(self): ...

View File

@@ -1,6 +1,6 @@
import sys
from types import TracebackType
from typing import Any, ClassVar, Literal
from typing import ClassVar, Literal
from typing_extensions import Self
from ._distutils.errors import DistutilsError
@@ -62,4 +62,4 @@ class DirectorySandbox(AbstractSandbox):
def open(self, file, flags, mode: int = 511, *args, **kw): ... # type: ignore[override]
class SandboxViolation(DistutilsError):
tmpl: Any
tmpl: str

View File

@@ -1,14 +1,14 @@
from _typeshed import Incomplete
from collections.abc import Generator
from typing import Any
WHEEL_NAME: Any
WHEEL_NAME: Incomplete
NAMESPACE_PACKAGE_INIT: str
def unpack(src_dir, dst_dir) -> None: ...
def disable_info_traces() -> Generator[None, None, None]: ...
class Wheel:
filename: Any
filename: Incomplete
def __init__(self, filename) -> None: ...
def tags(self): ...
def is_compatible(self): ...