From ae22ac23902ec2aa8c0989b0d30ff6562a67bb06 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 17 Oct 2024 16:38:40 -0400 Subject: [PATCH 1/6] Config changes to use our custom stubs --- mypy.ini | 11 +++++------ pyproject.toml | 4 ++++ pyrightconfig.json | 2 ++ ruff.toml | 3 +++ setuptools/command/sdist.py | 3 ++- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/mypy.ini b/mypy.ini index 26692755ea..f0335cce9d 100644 --- a/mypy.ini +++ b/mypy.ini @@ -18,6 +18,9 @@ disable_error_code = ## local +# Use our custom stubs for distutils +mypy_path = $MYPY_CONFIG_FILE_DIR/typings + # CI should test for all versions, local development gets hints for oldest supported # But our testing setup doesn't allow passing CLI arguments, so local devs have to set this manually. # python_version = 3.8 @@ -46,12 +49,8 @@ disable_error_code = attr-defined [mypy-pkg_resources.tests.*] disable_error_code = import-not-found -# - distutils doesn't exist on Python 3.12, unfortunately, this means typing -# will be missing for subclasses of distutils on Python 3.12 until either: -# - support for `SETUPTOOLS_USE_DISTUTILS=stdlib` is dropped (#3625) -# for setuptools to import `_distutils` directly -# - or non-stdlib distutils typings are exposed # - The following are not marked as py.typed: +# - jaraco: Since mypy 1.12, the root name of the untyped namespace package gets called-out too # - jaraco.develop: https://github.com/jaraco/jaraco.develop/issues/22 # - jaraco.envs: https://github.com/jaraco/jaraco.envs/issues/7 # - jaraco.packaging: https://github.com/jaraco/jaraco.packaging/issues/20 @@ -59,7 +58,7 @@ disable_error_code = import-not-found # - jaraco.test: https://github.com/jaraco/jaraco.test/issues/7 # - jaraco.text: https://github.com/jaraco/jaraco.text/issues/17 # - wheel: does not intend on exposing a programmatic API https://github.com/pypa/wheel/pull/610#issuecomment-2081687671 -[mypy-distutils.*,jaraco.develop,jaraco.envs,jaraco.packaging.*,jaraco.path,jaraco.test.*,jaraco.text,wheel.*] +[mypy-jaraco,jaraco.develop,jaraco.envs,jaraco.packaging.*,jaraco.path,jaraco.test.*,jaraco.text,wheel.*] ignore_missing_imports = True # Even when excluding a module, import issues can show up due to following import diff --git a/pyproject.toml b/pyproject.toml index eb6ec11041..d4fd934917 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -133,6 +133,8 @@ type = [ # local + # Referenced in distutils-stubs + "types-docutils", # pin mypy version so a new version doesn't suddenly cause the CI to fail, # until types-setuptools is removed from typeshed. # For help with static-typing issues, or mypy update, ping @Avasam @@ -203,6 +205,8 @@ include-package-data = true include = [ "setuptools*", "pkg_resources*", + # TODO: Include distutils stubs with package once we're confident in them + # "typings/distutils-stubs", "_distutils_hack*", ] exclude = [ diff --git a/pyrightconfig.json b/pyrightconfig.json index 27a329e169..4d906d5553 100644 --- a/pyrightconfig.json +++ b/pyrightconfig.json @@ -12,6 +12,8 @@ ], // Our testing setup doesn't allow passing CLI arguments, so local devs have to set this manually. // "pythonVersion": "3.8", + // Allow using distutils-stubs on Python 3.12+ + "reportMissingModuleSource": false, // For now we don't mind if mypy's `type: ignore` comments accidentally suppresses pyright issues "enableTypeIgnoreComments": true, "typeCheckingMode": "basic", diff --git a/ruff.toml b/ruff.toml index b55b4e8067..e731b8d486 100644 --- a/ruff.toml +++ b/ruff.toml @@ -31,6 +31,9 @@ ignore = [ # Only enforcing return type annotations for public functions "ANN202", # missing-return-type-private-function "ANN204", # missing-return-type-special-method + # Typeshed doesn't want complex or non-literal defaults for maintenance and testing reasons. + # This doesn't affect us, let's have more complete stubs. + "PYI011", # typed-argument-default-in-stub # https://docs.astral.sh/ruff/formatter/#conflicting-lint-rules "W191", diff --git a/setuptools/command/sdist.py b/setuptools/command/sdist.py index fa9a2c4d81..65ce735dde 100644 --- a/setuptools/command/sdist.py +++ b/setuptools/command/sdist.py @@ -4,6 +4,7 @@ import os import re from itertools import chain +from typing import ClassVar from .._importlib import metadata from ..dist import Distribution @@ -49,7 +50,7 @@ class sdist(orig.sdist): ] distribution: Distribution # override distutils.dist.Distribution with setuptools.dist.Distribution - negative_opt: dict[str, str] = {} + negative_opt: ClassVar[dict[str, str]] = {} README_EXTENSIONS = ['', '.rst', '.txt', '.md'] READMES = tuple('README{0}'.format(ext) for ext in README_EXTENSIONS) From bb9209934a9242cc576dce2fe8bcad2176d0d50e Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 17 Oct 2024 16:39:57 -0400 Subject: [PATCH 2/6] Vendor stdlib distutils from typeshed --- typings/distutils-stubs/__init__.pyi | 5 + typings/distutils-stubs/archive_util.pyi | 35 ++ typings/distutils-stubs/bcppcompiler.pyi | 3 + typings/distutils-stubs/ccompiler.pyi | 176 ++++++++++ typings/distutils-stubs/cmd.pyi | 229 +++++++++++++ typings/distutils-stubs/command/__init__.pyi | 48 +++ typings/distutils-stubs/command/bdist.pyi | 27 ++ .../distutils-stubs/command/bdist_dumb.pyi | 21 ++ typings/distutils-stubs/command/bdist_msi.pyi | 45 +++ .../command/bdist_packager.pyi | 0 typings/distutils-stubs/command/bdist_rpm.pyi | 52 +++ .../distutils-stubs/command/bdist_wininst.pyi | 16 + typings/distutils-stubs/command/build.pyi | 34 ++ .../distutils-stubs/command/build_clib.pyi | 29 ++ typings/distutils-stubs/command/build_ext.pyi | 52 +++ typings/distutils-stubs/command/build_py.pyi | 44 +++ .../distutils-stubs/command/build_scripts.pyi | 24 ++ typings/distutils-stubs/command/check.pyi | 39 +++ typings/distutils-stubs/command/clean.pyi | 17 + typings/distutils-stubs/command/config.pyi | 84 +++++ typings/distutils-stubs/command/install.pyi | 70 ++++ .../distutils-stubs/command/install_data.pyi | 19 ++ .../command/install_egg_info.pyi | 18 + .../command/install_headers.pyi | 16 + .../distutils-stubs/command/install_lib.pyi | 25 ++ .../command/install_scripts.pyi | 18 + typings/distutils-stubs/command/register.pyi | 20 ++ typings/distutils-stubs/command/sdist.pyi | 45 +++ typings/distutils-stubs/command/upload.pyi | 17 + typings/distutils-stubs/config.pyi | 17 + typings/distutils-stubs/core.pyi | 57 ++++ typings/distutils-stubs/cygwinccompiler.pyi | 20 ++ typings/distutils-stubs/debug.pyi | 3 + typings/distutils-stubs/dep_util.pyi | 14 + typings/distutils-stubs/dir_util.pyi | 23 ++ typings/distutils-stubs/dist.pyi | 317 ++++++++++++++++++ typings/distutils-stubs/errors.pyi | 19 ++ typings/distutils-stubs/extension.pyi | 36 ++ typings/distutils-stubs/fancy_getopt.pyi | 34 ++ typings/distutils-stubs/file_util.pyi | 38 +++ typings/distutils-stubs/filelist.pyi | 58 ++++ typings/distutils-stubs/log.pyi | 25 ++ typings/distutils-stubs/msvccompiler.pyi | 3 + typings/distutils-stubs/spawn.pyi | 6 + typings/distutils-stubs/sysconfig.pyi | 33 ++ typings/distutils-stubs/text_file.pyi | 21 ++ typings/distutils-stubs/unixccompiler.pyi | 3 + typings/distutils-stubs/util.pyi | 53 +++ typings/distutils-stubs/version.pyi | 36 ++ 49 files changed, 2044 insertions(+) create mode 100644 typings/distutils-stubs/__init__.pyi create mode 100644 typings/distutils-stubs/archive_util.pyi create mode 100644 typings/distutils-stubs/bcppcompiler.pyi create mode 100644 typings/distutils-stubs/ccompiler.pyi create mode 100644 typings/distutils-stubs/cmd.pyi create mode 100644 typings/distutils-stubs/command/__init__.pyi create mode 100644 typings/distutils-stubs/command/bdist.pyi create mode 100644 typings/distutils-stubs/command/bdist_dumb.pyi create mode 100644 typings/distutils-stubs/command/bdist_msi.pyi create mode 100644 typings/distutils-stubs/command/bdist_packager.pyi create mode 100644 typings/distutils-stubs/command/bdist_rpm.pyi create mode 100644 typings/distutils-stubs/command/bdist_wininst.pyi create mode 100644 typings/distutils-stubs/command/build.pyi create mode 100644 typings/distutils-stubs/command/build_clib.pyi create mode 100644 typings/distutils-stubs/command/build_ext.pyi create mode 100644 typings/distutils-stubs/command/build_py.pyi create mode 100644 typings/distutils-stubs/command/build_scripts.pyi create mode 100644 typings/distutils-stubs/command/check.pyi create mode 100644 typings/distutils-stubs/command/clean.pyi create mode 100644 typings/distutils-stubs/command/config.pyi create mode 100644 typings/distutils-stubs/command/install.pyi create mode 100644 typings/distutils-stubs/command/install_data.pyi create mode 100644 typings/distutils-stubs/command/install_egg_info.pyi create mode 100644 typings/distutils-stubs/command/install_headers.pyi create mode 100644 typings/distutils-stubs/command/install_lib.pyi create mode 100644 typings/distutils-stubs/command/install_scripts.pyi create mode 100644 typings/distutils-stubs/command/register.pyi create mode 100644 typings/distutils-stubs/command/sdist.pyi create mode 100644 typings/distutils-stubs/command/upload.pyi create mode 100644 typings/distutils-stubs/config.pyi create mode 100644 typings/distutils-stubs/core.pyi create mode 100644 typings/distutils-stubs/cygwinccompiler.pyi create mode 100644 typings/distutils-stubs/debug.pyi create mode 100644 typings/distutils-stubs/dep_util.pyi create mode 100644 typings/distutils-stubs/dir_util.pyi create mode 100644 typings/distutils-stubs/dist.pyi create mode 100644 typings/distutils-stubs/errors.pyi create mode 100644 typings/distutils-stubs/extension.pyi create mode 100644 typings/distutils-stubs/fancy_getopt.pyi create mode 100644 typings/distutils-stubs/file_util.pyi create mode 100644 typings/distutils-stubs/filelist.pyi create mode 100644 typings/distutils-stubs/log.pyi create mode 100644 typings/distutils-stubs/msvccompiler.pyi create mode 100644 typings/distutils-stubs/spawn.pyi create mode 100644 typings/distutils-stubs/sysconfig.pyi create mode 100644 typings/distutils-stubs/text_file.pyi create mode 100644 typings/distutils-stubs/unixccompiler.pyi create mode 100644 typings/distutils-stubs/util.pyi create mode 100644 typings/distutils-stubs/version.pyi diff --git a/typings/distutils-stubs/__init__.pyi b/typings/distutils-stubs/__init__.pyi new file mode 100644 index 0000000000..328a5b7834 --- /dev/null +++ b/typings/distutils-stubs/__init__.pyi @@ -0,0 +1,5 @@ +# Attempts to improve these stubs are probably not the best use of time: +# - distutils is deleted in Python 3.12 and newer +# - Most users already do not use stdlib distutils, due to setuptools monkeypatching +# - We have very little quality assurance on these stubs, since due to the two above issues +# we allowlist all distutils errors in stubtest. diff --git a/typings/distutils-stubs/archive_util.pyi b/typings/distutils-stubs/archive_util.pyi new file mode 100644 index 0000000000..16684ff069 --- /dev/null +++ b/typings/distutils-stubs/archive_util.pyi @@ -0,0 +1,35 @@ +from _typeshed import StrOrBytesPath, StrPath +from typing import Literal, overload + +@overload +def make_archive( + base_name: str, + format: str, + root_dir: StrOrBytesPath | None = None, + base_dir: str | None = None, + verbose: bool | Literal[0, 1] = 0, + dry_run: bool | Literal[0, 1] = 0, + owner: str | None = None, + group: str | None = None, +) -> str: ... +@overload +def make_archive( + base_name: StrPath, + format: str, + root_dir: StrOrBytesPath, + base_dir: str | None = None, + verbose: bool | Literal[0, 1] = 0, + dry_run: bool | Literal[0, 1] = 0, + owner: str | None = None, + group: str | None = None, +) -> str: ... +def make_tarball( + base_name: str, + base_dir: StrPath, + compress: str | None = "gzip", + verbose: bool | Literal[0, 1] = 0, + dry_run: bool | Literal[0, 1] = 0, + owner: str | None = None, + group: str | None = None, +) -> str: ... +def make_zipfile(base_name: str, base_dir: str, verbose: bool | Literal[0, 1] = 0, dry_run: bool | Literal[0, 1] = 0) -> str: ... diff --git a/typings/distutils-stubs/bcppcompiler.pyi b/typings/distutils-stubs/bcppcompiler.pyi new file mode 100644 index 0000000000..3e432f94b5 --- /dev/null +++ b/typings/distutils-stubs/bcppcompiler.pyi @@ -0,0 +1,3 @@ +from distutils.ccompiler import CCompiler + +class BCPPCompiler(CCompiler): ... diff --git a/typings/distutils-stubs/ccompiler.pyi b/typings/distutils-stubs/ccompiler.pyi new file mode 100644 index 0000000000..e0f33f430e --- /dev/null +++ b/typings/distutils-stubs/ccompiler.pyi @@ -0,0 +1,176 @@ +from _typeshed import BytesPath, StrPath, Unused +from collections.abc import Callable, Iterable +from distutils.file_util import _BytesPathT, _StrPathT +from typing import Literal, overload +from typing_extensions import TypeAlias, TypeVarTuple, Unpack + +_Macro: TypeAlias = tuple[str] | tuple[str, str | None] +_Ts = TypeVarTuple("_Ts") + +def gen_lib_options( + compiler: CCompiler, library_dirs: list[str], runtime_library_dirs: list[str], libraries: list[str] +) -> list[str]: ... +def gen_preprocess_options(macros: list[_Macro], include_dirs: list[str]) -> list[str]: ... +def get_default_compiler(osname: str | None = None, platform: str | None = None) -> str: ... +def new_compiler( + plat: str | None = None, + compiler: str | None = None, + verbose: bool | Literal[0, 1] = 0, + dry_run: bool | Literal[0, 1] = 0, + force: bool | Literal[0, 1] = 0, +) -> CCompiler: ... +def show_compilers() -> None: ... + +class CCompiler: + dry_run: bool + force: bool + verbose: bool + output_dir: str | None + macros: list[_Macro] + include_dirs: list[str] + libraries: list[str] + library_dirs: list[str] + runtime_library_dirs: list[str] + objects: list[str] + def __init__( + self, verbose: bool | Literal[0, 1] = 0, dry_run: bool | Literal[0, 1] = 0, force: bool | Literal[0, 1] = 0 + ) -> None: ... + def add_include_dir(self, dir: str) -> None: ... + def set_include_dirs(self, dirs: list[str]) -> None: ... + def add_library(self, libname: str) -> None: ... + def set_libraries(self, libnames: list[str]) -> None: ... + def add_library_dir(self, dir: str) -> None: ... + def set_library_dirs(self, dirs: list[str]) -> None: ... + def add_runtime_library_dir(self, dir: str) -> None: ... + def set_runtime_library_dirs(self, dirs: list[str]) -> None: ... + def define_macro(self, name: str, value: str | None = None) -> None: ... + def undefine_macro(self, name: str) -> None: ... + def add_link_object(self, object: str) -> None: ... + def set_link_objects(self, objects: list[str]) -> None: ... + def detect_language(self, sources: str | list[str]) -> str | None: ... + def find_library_file(self, dirs: list[str], lib: str, debug: bool | Literal[0, 1] = 0) -> str | None: ... + def has_function( + self, + funcname: str, + includes: list[str] | None = None, + include_dirs: list[str] | None = None, + libraries: list[str] | None = None, + library_dirs: list[str] | None = None, + ) -> bool: ... + def library_dir_option(self, dir: str) -> str: ... + def library_option(self, lib: str) -> str: ... + def runtime_library_dir_option(self, dir: str) -> str: ... + def set_executables(self, **args: str) -> None: ... + def compile( + self, + sources: list[str], + output_dir: str | None = None, + macros: list[_Macro] | None = None, + include_dirs: list[str] | None = None, + debug: bool | Literal[0, 1] = 0, + extra_preargs: list[str] | None = None, + extra_postargs: list[str] | None = None, + depends: list[str] | None = None, + ) -> list[str]: ... + def create_static_lib( + self, + objects: list[str], + output_libname: str, + output_dir: str | None = None, + debug: bool | Literal[0, 1] = 0, + target_lang: str | None = None, + ) -> None: ... + def link( + self, + target_desc: str, + objects: list[str], + output_filename: str, + output_dir: str | None = None, + libraries: list[str] | None = None, + library_dirs: list[str] | None = None, + runtime_library_dirs: list[str] | None = None, + export_symbols: list[str] | None = None, + debug: bool | Literal[0, 1] = 0, + extra_preargs: list[str] | None = None, + extra_postargs: list[str] | None = None, + build_temp: str | None = None, + target_lang: str | None = None, + ) -> None: ... + def link_executable( + self, + objects: list[str], + output_progname: str, + output_dir: str | None = None, + libraries: list[str] | None = None, + library_dirs: list[str] | None = None, + runtime_library_dirs: list[str] | None = None, + debug: bool | Literal[0, 1] = 0, + extra_preargs: list[str] | None = None, + extra_postargs: list[str] | None = None, + target_lang: str | None = None, + ) -> None: ... + def link_shared_lib( + self, + objects: list[str], + output_libname: str, + output_dir: str | None = None, + libraries: list[str] | None = None, + library_dirs: list[str] | None = None, + runtime_library_dirs: list[str] | None = None, + export_symbols: list[str] | None = None, + debug: bool | Literal[0, 1] = 0, + extra_preargs: list[str] | None = None, + extra_postargs: list[str] | None = None, + build_temp: str | None = None, + target_lang: str | None = None, + ) -> None: ... + def link_shared_object( + self, + objects: list[str], + output_filename: str, + output_dir: str | None = None, + libraries: list[str] | None = None, + library_dirs: list[str] | None = None, + runtime_library_dirs: list[str] | None = None, + export_symbols: list[str] | None = None, + debug: bool | Literal[0, 1] = 0, + extra_preargs: list[str] | None = None, + extra_postargs: list[str] | None = None, + build_temp: str | None = None, + target_lang: str | None = None, + ) -> None: ... + def preprocess( + self, + source: str, + output_file: str | None = None, + macros: list[_Macro] | None = None, + include_dirs: list[str] | None = None, + extra_preargs: list[str] | None = None, + extra_postargs: list[str] | None = None, + ) -> None: ... + @overload + def executable_filename(self, basename: str, strip_dir: Literal[0, False] = 0, output_dir: StrPath = "") -> str: ... + @overload + def executable_filename(self, basename: StrPath, strip_dir: Literal[1, True], output_dir: StrPath = "") -> str: ... + def library_filename( + self, libname: str, lib_type: str = "static", strip_dir: bool | Literal[0, 1] = 0, output_dir: StrPath = "" + ) -> str: ... + def object_filenames( + self, source_filenames: Iterable[StrPath], strip_dir: bool | Literal[0, 1] = 0, output_dir: StrPath | None = "" + ) -> list[str]: ... + @overload + def shared_object_filename(self, basename: str, strip_dir: Literal[0, False] = 0, output_dir: StrPath = "") -> str: ... + @overload + def shared_object_filename(self, basename: StrPath, strip_dir: Literal[1, True], output_dir: StrPath = "") -> str: ... + def execute( + self, func: Callable[[Unpack[_Ts]], Unused], args: tuple[Unpack[_Ts]], msg: str | None = None, level: int = 1 + ) -> None: ... + def spawn(self, cmd: list[str]) -> None: ... + def mkpath(self, name: str, mode: int = 0o777) -> None: ... + @overload + def move_file(self, src: StrPath, dst: _StrPathT) -> _StrPathT | str: ... + @overload + def move_file(self, src: BytesPath, dst: _BytesPathT) -> _BytesPathT | bytes: ... + def announce(self, msg: str, level: int = 1) -> None: ... + def warn(self, msg: str) -> None: ... + def debug_print(self, msg: str) -> None: ... diff --git a/typings/distutils-stubs/cmd.pyi b/typings/distutils-stubs/cmd.pyi new file mode 100644 index 0000000000..dcb423a49b --- /dev/null +++ b/typings/distutils-stubs/cmd.pyi @@ -0,0 +1,229 @@ +from _typeshed import BytesPath, Incomplete, StrOrBytesPath, StrPath, Unused +from abc import abstractmethod +from collections.abc import Callable, Iterable +from distutils.command.bdist import bdist +from distutils.command.bdist_dumb import bdist_dumb +from distutils.command.bdist_rpm import bdist_rpm +from distutils.command.build import build +from distutils.command.build_clib import build_clib +from distutils.command.build_ext import build_ext +from distutils.command.build_py import build_py +from distutils.command.build_scripts import build_scripts +from distutils.command.check import check +from distutils.command.clean import clean +from distutils.command.config import config +from distutils.command.install import install +from distutils.command.install_data import install_data +from distutils.command.install_egg_info import install_egg_info +from distutils.command.install_headers import install_headers +from distutils.command.install_lib import install_lib +from distutils.command.install_scripts import install_scripts +from distutils.command.register import register +from distutils.command.sdist import sdist +from distutils.command.upload import upload +from distutils.dist import Distribution +from distutils.file_util import _BytesPathT, _StrPathT +from typing import Any, ClassVar, Literal, TypeVar, overload +from typing_extensions import TypeVarTuple, Unpack + +_CommandT = TypeVar("_CommandT", bound=Command) +_Ts = TypeVarTuple("_Ts") + +class Command: + dry_run: Literal[0, 1] # Exposed from __getattr_. Same as Distribution.dry_run + distribution: Distribution + # Any to work around variance issues + sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]] + def __init__(self, dist: Distribution) -> None: ... + @abstractmethod + def initialize_options(self) -> None: ... + @abstractmethod + def finalize_options(self) -> None: ... + @abstractmethod + def run(self) -> None: ... + def announce(self, msg: str, level: int = 1) -> None: ... + def debug_print(self, msg: str) -> None: ... + def ensure_string(self, option: str, default: str | None = None) -> 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: ... + # NOTE: This list comes directly from the distutils/command folder. Minus bdist_msi and bdist_wininst. + @overload + def get_finalized_command(self, command: Literal["bdist"], create: bool | Literal[0, 1] = 1) -> bdist: ... + @overload + def get_finalized_command(self, command: Literal["bdist_dumb"], create: bool | Literal[0, 1] = 1) -> bdist_dumb: ... + @overload + def get_finalized_command(self, command: Literal["bdist_rpm"], create: bool | Literal[0, 1] = 1) -> bdist_rpm: ... + @overload + def get_finalized_command(self, command: Literal["build"], create: bool | Literal[0, 1] = 1) -> build: ... + @overload + def get_finalized_command(self, command: Literal["build_clib"], create: bool | Literal[0, 1] = 1) -> build_clib: ... + @overload + def get_finalized_command(self, command: Literal["build_ext"], create: bool | Literal[0, 1] = 1) -> build_ext: ... + @overload + def get_finalized_command(self, command: Literal["build_py"], create: bool | Literal[0, 1] = 1) -> build_py: ... + @overload + def get_finalized_command(self, command: Literal["build_scripts"], create: bool | Literal[0, 1] = 1) -> build_scripts: ... + @overload + def get_finalized_command(self, command: Literal["check"], create: bool | Literal[0, 1] = 1) -> check: ... + @overload + def get_finalized_command(self, command: Literal["clean"], create: bool | Literal[0, 1] = 1) -> clean: ... + @overload + def get_finalized_command(self, command: Literal["config"], create: bool | Literal[0, 1] = 1) -> config: ... + @overload + def get_finalized_command(self, command: Literal["install"], create: bool | Literal[0, 1] = 1) -> install: ... + @overload + def get_finalized_command(self, command: Literal["install_data"], create: bool | Literal[0, 1] = 1) -> install_data: ... + @overload + def get_finalized_command( + self, command: Literal["install_egg_info"], create: bool | Literal[0, 1] = 1 + ) -> install_egg_info: ... + @overload + def get_finalized_command(self, command: Literal["install_headers"], create: bool | Literal[0, 1] = 1) -> install_headers: ... + @overload + def get_finalized_command(self, command: Literal["install_lib"], create: bool | Literal[0, 1] = 1) -> install_lib: ... + @overload + def get_finalized_command(self, command: Literal["install_scripts"], create: bool | Literal[0, 1] = 1) -> install_scripts: ... + @overload + def get_finalized_command(self, command: Literal["register"], create: bool | Literal[0, 1] = 1) -> register: ... + @overload + def get_finalized_command(self, command: Literal["sdist"], create: bool | Literal[0, 1] = 1) -> sdist: ... + @overload + def get_finalized_command(self, command: Literal["upload"], create: bool | Literal[0, 1] = 1) -> upload: ... + @overload + def get_finalized_command(self, command: str, create: bool | Literal[0, 1] = 1) -> Command: ... + @overload + def reinitialize_command(self, command: Literal["bdist"], reinit_subcommands: bool | Literal[0, 1] = 0) -> bdist: ... + @overload + def reinitialize_command( + self, command: Literal["bdist_dumb"], reinit_subcommands: bool | Literal[0, 1] = 0 + ) -> bdist_dumb: ... + @overload + def reinitialize_command(self, command: Literal["bdist_rpm"], reinit_subcommands: bool | Literal[0, 1] = 0) -> bdist_rpm: ... + @overload + def reinitialize_command(self, command: Literal["build"], reinit_subcommands: bool | Literal[0, 1] = 0) -> build: ... + @overload + def reinitialize_command( + self, command: Literal["build_clib"], reinit_subcommands: bool | Literal[0, 1] = 0 + ) -> build_clib: ... + @overload + def reinitialize_command(self, command: Literal["build_ext"], reinit_subcommands: bool | Literal[0, 1] = 0) -> build_ext: ... + @overload + def reinitialize_command(self, command: Literal["build_py"], reinit_subcommands: bool | Literal[0, 1] = 0) -> build_py: ... + @overload + def reinitialize_command( + self, command: Literal["build_scripts"], reinit_subcommands: bool | Literal[0, 1] = 0 + ) -> build_scripts: ... + @overload + def reinitialize_command(self, command: Literal["check"], reinit_subcommands: bool | Literal[0, 1] = 0) -> check: ... + @overload + def reinitialize_command(self, command: Literal["clean"], reinit_subcommands: bool | Literal[0, 1] = 0) -> clean: ... + @overload + def reinitialize_command(self, command: Literal["config"], reinit_subcommands: bool | Literal[0, 1] = 0) -> config: ... + @overload + def reinitialize_command(self, command: Literal["install"], reinit_subcommands: bool | Literal[0, 1] = 0) -> install: ... + @overload + def reinitialize_command( + self, command: Literal["install_data"], reinit_subcommands: bool | Literal[0, 1] = 0 + ) -> install_data: ... + @overload + def reinitialize_command( + self, command: Literal["install_egg_info"], reinit_subcommands: bool | Literal[0, 1] = 0 + ) -> install_egg_info: ... + @overload + def reinitialize_command( + self, command: Literal["install_headers"], reinit_subcommands: bool | Literal[0, 1] = 0 + ) -> install_headers: ... + @overload + def reinitialize_command( + self, command: Literal["install_lib"], reinit_subcommands: bool | Literal[0, 1] = 0 + ) -> install_lib: ... + @overload + def reinitialize_command( + self, command: Literal["install_scripts"], reinit_subcommands: bool | Literal[0, 1] = 0 + ) -> install_scripts: ... + @overload + def reinitialize_command(self, command: Literal["register"], reinit_subcommands: bool | Literal[0, 1] = 0) -> register: ... + @overload + def reinitialize_command(self, command: Literal["sdist"], reinit_subcommands: bool | Literal[0, 1] = 0) -> sdist: ... + @overload + def reinitialize_command(self, command: Literal["upload"], reinit_subcommands: bool | Literal[0, 1] = 0) -> upload: ... + @overload + def reinitialize_command(self, command: str, reinit_subcommands: bool | Literal[0, 1] = 0) -> Command: ... + @overload + def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool | Literal[0, 1] = 0) -> _CommandT: ... + def run_command(self, command: str) -> None: ... + def get_sub_commands(self) -> list[str]: ... + def warn(self, msg: str) -> None: ... + def execute( + self, func: Callable[[Unpack[_Ts]], Unused], args: tuple[Unpack[_Ts]], msg: str | None = None, level: int = 1 + ) -> None: ... + def mkpath(self, name: str, mode: int = 0o777) -> None: ... + @overload + def copy_file( + self, + infile: StrPath, + outfile: _StrPathT, + preserve_mode: bool | Literal[0, 1] = 1, + preserve_times: bool | Literal[0, 1] = 1, + link: str | None = None, + level: Unused = 1, + ) -> tuple[_StrPathT | str, bool]: ... + @overload + def copy_file( + self, + infile: BytesPath, + outfile: _BytesPathT, + preserve_mode: bool | Literal[0, 1] = 1, + preserve_times: bool | Literal[0, 1] = 1, + link: str | None = None, + level: Unused = 1, + ) -> tuple[_BytesPathT | bytes, bool]: ... + def copy_tree( + self, + infile: StrPath, + outfile: str, + preserve_mode: bool | Literal[0, 1] = 1, + preserve_times: bool | Literal[0, 1] = 1, + preserve_symlinks: bool | Literal[0, 1] = 0, + level: Unused = 1, + ) -> list[str]: ... + @overload + def move_file(self, src: StrPath, dst: _StrPathT, level: Unused = 1) -> _StrPathT | str: ... + @overload + def move_file(self, src: BytesPath, dst: _BytesPathT, level: Unused = 1) -> _BytesPathT | bytes: ... + def spawn(self, cmd: Iterable[str], search_path: bool | Literal[0, 1] = 1, level: Unused = 1) -> None: ... + @overload + def make_archive( + self, + base_name: str, + format: str, + root_dir: StrOrBytesPath | None = None, + base_dir: str | None = None, + owner: str | None = None, + group: str | None = None, + ) -> str: ... + @overload + def make_archive( + self, + base_name: StrPath, + format: str, + root_dir: StrOrBytesPath, + base_dir: str | None = None, + owner: str | None = None, + group: str | None = None, + ) -> str: ... + def make_file( + self, + infiles: str | list[str] | tuple[str, ...], + outfile: StrOrBytesPath, + func: Callable[[Unpack[_Ts]], Unused], + args: tuple[Unpack[_Ts]], + exec_msg: str | None = None, + skip_msg: str | None = None, + level: Unused = 1, + ) -> None: ... + def ensure_finalized(self) -> None: ... + def dump_options(self, header: Incomplete | None = None, indent: str = "") -> None: ... diff --git a/typings/distutils-stubs/command/__init__.pyi b/typings/distutils-stubs/command/__init__.pyi new file mode 100644 index 0000000000..4d7372858a --- /dev/null +++ b/typings/distutils-stubs/command/__init__.pyi @@ -0,0 +1,48 @@ +import sys + +from . import ( + bdist, + bdist_dumb, + bdist_rpm, + build, + build_clib, + build_ext, + build_py, + build_scripts, + check, + clean, + install, + install_data, + install_headers, + install_lib, + install_scripts, + register, + sdist, + upload, +) + +__all__ = [ + "build", + "build_py", + "build_ext", + "build_clib", + "build_scripts", + "clean", + "install", + "install_lib", + "install_headers", + "install_scripts", + "install_data", + "sdist", + "register", + "bdist", + "bdist_dumb", + "bdist_rpm", + "check", + "upload", +] + +if sys.version_info < (3, 10): + from . import bdist_wininst + + __all__ += ["bdist_wininst"] diff --git a/typings/distutils-stubs/command/bdist.pyi b/typings/distutils-stubs/command/bdist.pyi new file mode 100644 index 0000000000..43d77087f7 --- /dev/null +++ b/typings/distutils-stubs/command/bdist.pyi @@ -0,0 +1,27 @@ +from _typeshed import Unused +from collections.abc import Callable +from typing import Any, ClassVar + +from ..cmd import Command + +def show_formats() -> None: ... + +class bdist(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], Unused]]]] + no_format_option: ClassVar[tuple[str, ...]] + default_format: ClassVar[dict[str, str]] + format_commands: ClassVar[list[str]] + format_command: ClassVar[dict[str, tuple[str, str]]] + bdist_base: Any + plat_name: Any + formats: Any + dist_dir: Any + skip_build: int + group: Any + owner: Any + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... diff --git a/typings/distutils-stubs/command/bdist_dumb.pyi b/typings/distutils-stubs/command/bdist_dumb.pyi new file mode 100644 index 0000000000..19997882dd --- /dev/null +++ b/typings/distutils-stubs/command/bdist_dumb.pyi @@ -0,0 +1,21 @@ +from typing import Any, ClassVar + +from ..cmd import Command + +class bdist_dumb(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + default_format: ClassVar[dict[str, str]] + bdist_dir: Any + plat_name: Any + format: Any + keep_temp: int + dist_dir: Any + skip_build: Any + relative: int + owner: Any + group: Any + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... diff --git a/typings/distutils-stubs/command/bdist_msi.pyi b/typings/distutils-stubs/command/bdist_msi.pyi new file mode 100644 index 0000000000..d0eac1a3be --- /dev/null +++ b/typings/distutils-stubs/command/bdist_msi.pyi @@ -0,0 +1,45 @@ +import sys +from typing import Any, ClassVar, Literal + +from ..cmd import Command + +if sys.platform == "win32": + from msilib import Dialog + + class PyDialog(Dialog): + def __init__(self, *args, **kw) -> None: ... + def title(self, title) -> None: ... + def back(self, title, next, name: str = "Back", active: bool | Literal[0, 1] = 1): ... + def cancel(self, title, next, name: str = "Cancel", active: bool | Literal[0, 1] = 1): ... + def next(self, title, next, name: str = "Next", active: bool | Literal[0, 1] = 1): ... + def xbutton(self, name, title, next, xpos): ... + + class bdist_msi(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + all_versions: Any + other_version: str + if sys.version_info >= (3, 9): + def __init__(self, *args, **kw) -> None: ... + bdist_dir: Any + plat_name: Any + keep_temp: int + no_target_compile: int + no_target_optimize: int + target_version: Any + dist_dir: Any + skip_build: Any + install_script: Any + pre_install_script: Any + versions: Any + def initialize_options(self) -> None: ... + install_script_key: Any + def finalize_options(self) -> None: ... + db: Any + def run(self) -> None: ... + def add_files(self) -> None: ... + def add_find_python(self) -> None: ... + def add_scripts(self) -> None: ... + def add_ui(self) -> None: ... + def get_installer_filename(self, fullname): ... diff --git a/typings/distutils-stubs/command/bdist_packager.pyi b/typings/distutils-stubs/command/bdist_packager.pyi new file mode 100644 index 0000000000..e69de29bb2 diff --git a/typings/distutils-stubs/command/bdist_rpm.pyi b/typings/distutils-stubs/command/bdist_rpm.pyi new file mode 100644 index 0000000000..89c43e1b97 --- /dev/null +++ b/typings/distutils-stubs/command/bdist_rpm.pyi @@ -0,0 +1,52 @@ +from typing import Any, ClassVar + +from ..cmd import Command + +class bdist_rpm(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + negative_opt: ClassVar[dict[str, str]] + bdist_base: Any + rpm_base: Any + dist_dir: Any + python: Any + fix_python: Any + spec_only: Any + binary_only: Any + source_only: Any + use_bzip2: Any + distribution_name: Any + group: Any + release: Any + serial: Any + vendor: Any + packager: Any + doc_files: Any + changelog: Any + icon: Any + prep_script: Any + build_script: Any + install_script: Any + clean_script: Any + verify_script: Any + pre_install: Any + post_install: Any + pre_uninstall: Any + post_uninstall: Any + prep: Any + provides: Any + requires: Any + conflicts: Any + build_requires: Any + obsoletes: Any + keep_temp: int + use_rpm_opt_flags: int + rpm3_mode: int + no_autoreq: int + force_arch: Any + quiet: int + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def finalize_package_data(self) -> None: ... + def run(self) -> None: ... diff --git a/typings/distutils-stubs/command/bdist_wininst.pyi b/typings/distutils-stubs/command/bdist_wininst.pyi new file mode 100644 index 0000000000..cf333bc540 --- /dev/null +++ b/typings/distutils-stubs/command/bdist_wininst.pyi @@ -0,0 +1,16 @@ +from _typeshed import StrOrBytesPath +from distutils.cmd import Command +from typing import ClassVar + +class bdist_wininst(Command): + description: ClassVar[str] + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def get_inidata(self) -> str: ... + def create_exe(self, arcname: StrOrBytesPath, fullname: str, bitmap: StrOrBytesPath | None = None) -> None: ... + def get_installer_filename(self, fullname: str) -> str: ... + def get_exe_bytes(self) -> bytes: ... diff --git a/typings/distutils-stubs/command/build.pyi b/typings/distutils-stubs/command/build.pyi new file mode 100644 index 0000000000..78ba6b7042 --- /dev/null +++ b/typings/distutils-stubs/command/build.pyi @@ -0,0 +1,34 @@ +from _typeshed import Unused +from collections.abc import Callable +from typing import Any, ClassVar + +from ..cmd import Command + +def show_compilers() -> None: ... + +class build(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], Unused]]]] + build_base: str + build_purelib: Any + build_platlib: Any + build_lib: Any + build_temp: Any + build_scripts: Any + compiler: Any + plat_name: Any + debug: Any + force: int + executable: Any + parallel: Any + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def has_pure_modules(self): ... + def has_c_libraries(self): ... + def has_ext_modules(self): ... + def has_scripts(self): ... + # Any to work around variance issues + sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]] diff --git a/typings/distutils-stubs/command/build_clib.pyi b/typings/distutils-stubs/command/build_clib.pyi new file mode 100644 index 0000000000..1f66e2efc2 --- /dev/null +++ b/typings/distutils-stubs/command/build_clib.pyi @@ -0,0 +1,29 @@ +from _typeshed import Unused +from collections.abc import Callable +from typing import Any, ClassVar + +from ..cmd import Command + +def show_compilers() -> None: ... + +class build_clib(Command): + description: str + user_options: ClassVar[list[tuple[str, str, str]]] + boolean_options: ClassVar[list[str]] + help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], Unused]]]] + build_clib: Any + build_temp: Any + libraries: Any + include_dirs: Any + define: Any + undef: Any + debug: Any + force: int + compiler: Any + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def check_library_list(self, libraries) -> None: ... + def get_library_names(self): ... + def get_source_files(self): ... + def build_libraries(self, libraries) -> None: ... diff --git a/typings/distutils-stubs/command/build_ext.pyi b/typings/distutils-stubs/command/build_ext.pyi new file mode 100644 index 0000000000..a0813c3140 --- /dev/null +++ b/typings/distutils-stubs/command/build_ext.pyi @@ -0,0 +1,52 @@ +from _typeshed import Unused +from collections.abc import Callable +from typing import Any, ClassVar + +from ..cmd import Command + +extension_name_re: Any + +def show_compilers() -> None: ... + +class build_ext(Command): + description: str + sep_by: Any + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], Unused]]]] + extensions: Any + build_lib: Any + plat_name: Any + build_temp: Any + inplace: int + package: Any + include_dirs: Any + define: Any + undef: Any + libraries: Any + library_dirs: Any + rpath: Any + link_objects: Any + debug: Any + force: Any + compiler: Any + swig: Any + swig_cpp: Any + swig_opts: Any + user: Any + parallel: Any + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def check_extensions_list(self, extensions) -> None: ... + def get_source_files(self): ... + def get_outputs(self): ... + def build_extensions(self) -> None: ... + def build_extension(self, ext) -> None: ... + def swig_sources(self, sources, extension): ... + def find_swig(self): ... + def get_ext_fullpath(self, ext_name: str) -> str: ... + def get_ext_fullname(self, ext_name: str) -> str: ... + def get_ext_filename(self, ext_name: str) -> str: ... + def get_export_symbols(self, ext): ... + def get_libraries(self, ext): ... diff --git a/typings/distutils-stubs/command/build_py.pyi b/typings/distutils-stubs/command/build_py.pyi new file mode 100644 index 0000000000..90f0675141 --- /dev/null +++ b/typings/distutils-stubs/command/build_py.pyi @@ -0,0 +1,44 @@ +from typing import Any, ClassVar, Literal + +from ..cmd import Command +from ..util import Mixin2to3 as Mixin2to3 + +class build_py(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + negative_opt: ClassVar[dict[str, str]] + build_lib: Any + py_modules: Any + package: Any + package_data: Any + package_dir: Any + compile: int + optimize: int + force: Any + def initialize_options(self) -> None: ... + packages: Any + data_files: Any + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def get_data_files(self): ... + def find_data_files(self, package, src_dir): ... + def build_package_data(self) -> None: ... + def get_package_dir(self, package): ... + def check_package(self, package, package_dir): ... + def check_module(self, module, module_file): ... + def find_package_modules(self, package, package_dir): ... + def find_modules(self): ... + def find_all_modules(self): ... + def get_source_files(self): ... + def get_module_outfile(self, build_dir, package, module): ... + def get_outputs(self, include_bytecode: bool | Literal[0, 1] = 1): ... + def build_module(self, module, module_file, package): ... + def build_modules(self) -> None: ... + def build_packages(self) -> None: ... + def byte_compile(self, files) -> None: ... + +class build_py_2to3(build_py, Mixin2to3): + updated_files: Any + def run(self) -> None: ... + def build_module(self, module, module_file, package): ... diff --git a/typings/distutils-stubs/command/build_scripts.pyi b/typings/distutils-stubs/command/build_scripts.pyi new file mode 100644 index 0000000000..7871bb8a57 --- /dev/null +++ b/typings/distutils-stubs/command/build_scripts.pyi @@ -0,0 +1,24 @@ +from typing import Any, ClassVar + +from ..cmd import Command +from ..util import Mixin2to3 as Mixin2to3 + +first_line_re: Any + +class build_scripts(Command): + description: str + user_options: ClassVar[list[tuple[str, str, str]]] + boolean_options: ClassVar[list[str]] + build_dir: Any + scripts: Any + force: Any + executable: Any + outfiles: Any + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def get_source_files(self): ... + def run(self) -> None: ... + def copy_scripts(self): ... + +class build_scripts_2to3(build_scripts, Mixin2to3): + def copy_scripts(self): ... diff --git a/typings/distutils-stubs/command/check.pyi b/typings/distutils-stubs/command/check.pyi new file mode 100644 index 0000000000..e69627d20c --- /dev/null +++ b/typings/distutils-stubs/command/check.pyi @@ -0,0 +1,39 @@ +from typing import Any, ClassVar, Final, Literal +from typing_extensions import TypeAlias + +from ..cmd import Command + +_Reporter: TypeAlias = Any # really docutils.utils.Reporter + +# Only defined if docutils is installed. +# Depends on a third-party stub. Since distutils is deprecated anyway, +# it's easier to just suppress the "any subclassing" error. +class SilentReporter(_Reporter): + messages: Any + def __init__( + self, + source, + report_level, + halt_level, + stream: Any | None = ..., + debug: bool | Literal[0, 1] = 0, + encoding: str = ..., + error_handler: str = ..., + ) -> None: ... + def system_message(self, level, message, *children, **kwargs): ... + +HAS_DOCUTILS: Final[bool] + +class check(Command): + description: str + user_options: ClassVar[list[tuple[str, str, str]]] + boolean_options: ClassVar[list[str]] + restructuredtext: int + metadata: int + strict: int + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def warn(self, msg): ... + def run(self) -> None: ... + def check_metadata(self) -> None: ... + def check_restructuredtext(self) -> None: ... diff --git a/typings/distutils-stubs/command/clean.pyi b/typings/distutils-stubs/command/clean.pyi new file mode 100644 index 0000000000..55f0a0eeaf --- /dev/null +++ b/typings/distutils-stubs/command/clean.pyi @@ -0,0 +1,17 @@ +from typing import Any, ClassVar + +from ..cmd import Command + +class clean(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + build_base: Any + build_lib: Any + build_temp: Any + build_scripts: Any + bdist_base: Any + all: Any + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... diff --git a/typings/distutils-stubs/command/config.pyi b/typings/distutils-stubs/command/config.pyi new file mode 100644 index 0000000000..b0910091d5 --- /dev/null +++ b/typings/distutils-stubs/command/config.pyi @@ -0,0 +1,84 @@ +from _typeshed import StrOrBytesPath +from collections.abc import Sequence +from re import Pattern +from typing import Any, ClassVar, Final, Literal + +from ..ccompiler import CCompiler +from ..cmd import Command + +LANG_EXT: Final[dict[str, str]] + +class config(Command): + description: str + # Tuple is full name, short name, description + user_options: ClassVar[list[tuple[str, str | None, str]]] + compiler: str | CCompiler + cc: str | None + include_dirs: Sequence[str] | None + libraries: Sequence[str] | None + library_dirs: Sequence[str] | None + noisy: int + dump_source: int + temp_files: Sequence[str] + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def try_cpp( + self, + body: str | None = None, + headers: Sequence[str] | None = None, + include_dirs: Sequence[str] | None = None, + lang: str = "c", + ) -> bool: ... + def search_cpp( + self, + pattern: Pattern[str] | str, + body: str | None = None, + headers: Sequence[str] | None = None, + include_dirs: Sequence[str] | None = None, + lang: str = "c", + ) -> bool: ... + def try_compile( + self, body: str, headers: Sequence[str] | None = None, include_dirs: Sequence[str] | None = None, lang: str = "c" + ) -> bool: ... + def try_link( + self, + body: str, + headers: Sequence[str] | None = None, + include_dirs: Sequence[str] | None = None, + libraries: Sequence[str] | None = None, + library_dirs: Sequence[str] | None = None, + lang: str = "c", + ) -> bool: ... + def try_run( + self, + body: str, + headers: Sequence[str] | None = None, + include_dirs: Sequence[str] | None = None, + libraries: Sequence[str] | None = None, + library_dirs: Sequence[str] | None = None, + lang: str = "c", + ) -> bool: ... + def check_func( + self, + func: str, + headers: Sequence[str] | None = None, + include_dirs: Sequence[str] | None = None, + libraries: Sequence[str] | None = None, + library_dirs: Sequence[str] | None = None, + decl: bool | Literal[0, 1] = 0, + call: bool | Literal[0, 1] = 0, + ) -> bool: ... + def check_lib( + self, + library: str, + library_dirs: Sequence[str] | None = None, + headers: Sequence[str] | None = None, + include_dirs: Sequence[str] | None = None, + other_libraries: list[str] = [], + ) -> bool: ... + def check_header( + self, header: str, include_dirs: Sequence[str] | None = None, library_dirs: Sequence[str] | None = None, lang: str = "c" + ) -> bool: ... + +def dump_file(filename: StrOrBytesPath, head: Any | None = None) -> None: ... diff --git a/typings/distutils-stubs/command/install.pyi b/typings/distutils-stubs/command/install.pyi new file mode 100644 index 0000000000..24a4eff2fb --- /dev/null +++ b/typings/distutils-stubs/command/install.pyi @@ -0,0 +1,70 @@ +import sys +from collections.abc import Callable +from typing import Any, ClassVar, Final, Literal + +from ..cmd import Command + +HAS_USER_SITE: Final[bool] + +SCHEME_KEYS: Final[tuple[Literal["purelib"], Literal["platlib"], Literal["headers"], Literal["scripts"], Literal["data"]]] +INSTALL_SCHEMES: Final[dict[str, dict[str, str]]] + +if sys.version_info < (3, 10): + WINDOWS_SCHEME: Final[dict[str, str]] + +class install(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + negative_opt: ClassVar[dict[str, str]] + prefix: str | None + exec_prefix: Any + home: str | None + user: bool + install_base: Any + install_platbase: Any + root: str | None + install_purelib: Any + install_platlib: Any + install_headers: Any + install_lib: str | None + install_scripts: Any + install_data: Any + install_userbase: Any + install_usersite: Any + compile: Any + optimize: Any + extra_path: Any + install_path_file: int + force: int + skip_build: int + warn_dir: int + build_base: Any + build_lib: Any + record: Any + def initialize_options(self) -> None: ... + config_vars: Any + install_libbase: Any + def finalize_options(self) -> None: ... + def dump_dirs(self, msg) -> None: ... + def finalize_unix(self) -> None: ... + def finalize_other(self) -> None: ... + def select_scheme(self, name) -> None: ... + def expand_basedirs(self) -> None: ... + def expand_dirs(self) -> None: ... + def convert_paths(self, *names) -> None: ... + path_file: Any + extra_dirs: Any + def handle_extra_path(self) -> None: ... + def change_roots(self, *names) -> None: ... + def create_home_path(self) -> None: ... + def run(self) -> None: ... + def create_path_file(self) -> None: ... + def get_outputs(self): ... + def get_inputs(self): ... + def has_lib(self): ... + def has_headers(self): ... + def has_scripts(self): ... + def has_data(self): ... + # Any to work around variance issues + sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]] diff --git a/typings/distutils-stubs/command/install_data.pyi b/typings/distutils-stubs/command/install_data.pyi new file mode 100644 index 0000000000..342c7a7ccc --- /dev/null +++ b/typings/distutils-stubs/command/install_data.pyi @@ -0,0 +1,19 @@ +from typing import Any, ClassVar + +from ..cmd import Command + +class install_data(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + install_dir: Any + outfiles: Any + root: Any + force: int + data_files: Any + warn_dir: int + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def get_inputs(self): ... + def get_outputs(self): ... diff --git a/typings/distutils-stubs/command/install_egg_info.pyi b/typings/distutils-stubs/command/install_egg_info.pyi new file mode 100644 index 0000000000..3fd54989d1 --- /dev/null +++ b/typings/distutils-stubs/command/install_egg_info.pyi @@ -0,0 +1,18 @@ +from typing import Any, ClassVar + +from ..cmd import Command + +class install_egg_info(Command): + description: ClassVar[str] + user_options: ClassVar[list[tuple[str, str, str]]] + install_dir: Any + def initialize_options(self) -> None: ... + target: Any + outputs: Any + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def get_outputs(self) -> list[str]: ... + +def safe_name(name): ... +def safe_version(version): ... +def to_filename(name): ... diff --git a/typings/distutils-stubs/command/install_headers.pyi b/typings/distutils-stubs/command/install_headers.pyi new file mode 100644 index 0000000000..7854d2393a --- /dev/null +++ b/typings/distutils-stubs/command/install_headers.pyi @@ -0,0 +1,16 @@ +from typing import Any, ClassVar + +from ..cmd import Command + +class install_headers(Command): + description: str + user_options: ClassVar[list[tuple[str, str, str]]] + boolean_options: ClassVar[list[str]] + install_dir: Any + force: int + outfiles: Any + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def get_inputs(self): ... + def get_outputs(self): ... diff --git a/typings/distutils-stubs/command/install_lib.pyi b/typings/distutils-stubs/command/install_lib.pyi new file mode 100644 index 0000000000..149ecae897 --- /dev/null +++ b/typings/distutils-stubs/command/install_lib.pyi @@ -0,0 +1,25 @@ +from typing import Any, ClassVar, Final + +from ..cmd import Command + +PYTHON_SOURCE_EXTENSION: Final = ".py" + +class install_lib(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + negative_opt: ClassVar[dict[str, str]] + install_dir: Any + build_dir: Any + force: int + compile: Any + optimize: Any + skip_build: Any + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def build(self) -> None: ... + def install(self): ... + def byte_compile(self, files) -> None: ... + def get_outputs(self): ... + def get_inputs(self): ... diff --git a/typings/distutils-stubs/command/install_scripts.pyi b/typings/distutils-stubs/command/install_scripts.pyi new file mode 100644 index 0000000000..5ee5589ad3 --- /dev/null +++ b/typings/distutils-stubs/command/install_scripts.pyi @@ -0,0 +1,18 @@ +from typing import Any, ClassVar + +from ..cmd import Command + +class install_scripts(Command): + description: str + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + install_dir: Any + force: int + build_dir: Any + skip_build: Any + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + outfiles: Any + def run(self) -> None: ... + def get_inputs(self): ... + def get_outputs(self): ... diff --git a/typings/distutils-stubs/command/register.pyi b/typings/distutils-stubs/command/register.pyi new file mode 100644 index 0000000000..a5e251d2d0 --- /dev/null +++ b/typings/distutils-stubs/command/register.pyi @@ -0,0 +1,20 @@ +from collections.abc import Callable +from typing import Any, ClassVar + +from ..config import PyPIRCCommand + +class register(PyPIRCCommand): + description: str + # Any to work around variance issues + sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]] + list_classifiers: int + strict: int + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def check_metadata(self) -> None: ... + def classifiers(self) -> None: ... + def verify_metadata(self) -> None: ... + def send_metadata(self) -> None: ... + def build_post_data(self, action): ... + def post_to_server(self, data, auth: Any | None = None): ... diff --git a/typings/distutils-stubs/command/sdist.pyi b/typings/distutils-stubs/command/sdist.pyi new file mode 100644 index 0000000000..5b7fe24195 --- /dev/null +++ b/typings/distutils-stubs/command/sdist.pyi @@ -0,0 +1,45 @@ +from _typeshed import Unused +from collections.abc import Callable +from typing import Any, ClassVar + +from ..cmd import Command + +def show_formats() -> None: ... + +class sdist(Command): + description: str + def checking_metadata(self): ... + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], Unused]]]] + negative_opt: ClassVar[dict[str, str]] + # Any to work around variance issues + sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]] + READMES: ClassVar[tuple[str, ...]] + template: Any + manifest: Any + use_defaults: int + prune: int + manifest_only: int + force_manifest: int + formats: Any + keep_temp: int + dist_dir: Any + archive_files: Any + metadata_check: int + owner: Any + group: Any + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + filelist: Any + def run(self) -> None: ... + def check_metadata(self) -> None: ... + def get_file_list(self) -> None: ... + def add_defaults(self) -> None: ... + def read_template(self) -> None: ... + def prune_file_list(self) -> None: ... + def write_manifest(self) -> None: ... + def read_manifest(self) -> None: ... + def make_release_tree(self, base_dir, files) -> None: ... + def make_distribution(self) -> None: ... + def get_archive_files(self): ... diff --git a/typings/distutils-stubs/command/upload.pyi b/typings/distutils-stubs/command/upload.pyi new file mode 100644 index 0000000000..e6b77825c5 --- /dev/null +++ b/typings/distutils-stubs/command/upload.pyi @@ -0,0 +1,17 @@ +from typing import Any, ClassVar + +from ..config import PyPIRCCommand + +class upload(PyPIRCCommand): + description: ClassVar[str] + username: str + password: str + show_response: int + sign: bool + identity: Any + def initialize_options(self) -> None: ... + repository: Any + realm: Any + def finalize_options(self) -> None: ... + def run(self) -> None: ... + def upload_file(self, command: str, pyversion: str, filename: str) -> None: ... diff --git a/typings/distutils-stubs/config.pyi b/typings/distutils-stubs/config.pyi new file mode 100644 index 0000000000..5814a82841 --- /dev/null +++ b/typings/distutils-stubs/config.pyi @@ -0,0 +1,17 @@ +from abc import abstractmethod +from distutils.cmd import Command +from typing import ClassVar + +DEFAULT_PYPIRC: str + +class PyPIRCCommand(Command): + DEFAULT_REPOSITORY: ClassVar[str] + DEFAULT_REALM: ClassVar[str] + repository: None + realm: None + user_options: ClassVar[list[tuple[str, str | None, str]]] + boolean_options: ClassVar[list[str]] + def initialize_options(self) -> None: ... + def finalize_options(self) -> None: ... + @abstractmethod + def run(self) -> None: ... diff --git a/typings/distutils-stubs/core.pyi b/typings/distutils-stubs/core.pyi new file mode 100644 index 0000000000..a4d21f8ddd --- /dev/null +++ b/typings/distutils-stubs/core.pyi @@ -0,0 +1,57 @@ +from _typeshed import StrOrBytesPath +from collections.abc import Mapping +from distutils.cmd import Command as Command +from distutils.dist import Distribution as Distribution +from distutils.extension import Extension as Extension +from typing import Any, Final, Literal + +USAGE: Final[str] + +def gen_usage(script_name: StrOrBytesPath) -> str: ... + +setup_keywords: tuple[str, ...] +extension_keywords: tuple[str, ...] + +def setup( + *, + name: str = ..., + version: str = ..., + description: str = ..., + long_description: str = ..., + author: str = ..., + author_email: str = ..., + maintainer: str = ..., + maintainer_email: str = ..., + url: str = ..., + download_url: str = ..., + packages: list[str] = ..., + py_modules: list[str] = ..., + scripts: list[str] = ..., + ext_modules: list[Extension] = ..., + classifiers: list[str] = ..., + distclass: type[Distribution] = ..., + script_name: str = ..., + script_args: list[str] = ..., + options: Mapping[str, Any] = ..., + license: str = ..., + keywords: list[str] | str = ..., + platforms: list[str] | str = ..., + cmdclass: Mapping[str, type[Command]] = ..., + data_files: list[tuple[str, list[str]]] = ..., + package_dir: Mapping[str, str] = ..., + obsoletes: list[str] = ..., + provides: list[str] = ..., + requires: list[str] = ..., + command_packages: list[str] = ..., + command_options: Mapping[str, Mapping[str, tuple[Any, Any]]] = ..., + package_data: Mapping[str, list[str]] = ..., + include_package_data: bool | Literal[0, 1] = ..., + libraries: list[str] = ..., + headers: list[str] = ..., + ext_package: str = ..., + include_dirs: list[str] = ..., + password: str = ..., + fullname: str = ..., + **attrs: Any, +) -> Distribution: ... +def run_setup(script_name: str, script_args: list[str] | None = None, stop_after: str = "run") -> Distribution: ... diff --git a/typings/distutils-stubs/cygwinccompiler.pyi b/typings/distutils-stubs/cygwinccompiler.pyi new file mode 100644 index 0000000000..80924d63e4 --- /dev/null +++ b/typings/distutils-stubs/cygwinccompiler.pyi @@ -0,0 +1,20 @@ +from distutils.unixccompiler import UnixCCompiler +from distutils.version import LooseVersion +from re import Pattern +from typing import Final, Literal + +def get_msvcr() -> list[str] | None: ... + +class CygwinCCompiler(UnixCCompiler): ... +class Mingw32CCompiler(CygwinCCompiler): ... + +CONFIG_H_OK: Final = "ok" +CONFIG_H_NOTOK: Final = "not ok" +CONFIG_H_UNCERTAIN: Final = "uncertain" + +def check_config_h() -> tuple[Literal["ok", "not ok", "uncertain"], str]: ... + +RE_VERSION: Final[Pattern[bytes]] + +def get_versions() -> tuple[LooseVersion | None, ...]: ... +def is_cygwingcc() -> bool: ... diff --git a/typings/distutils-stubs/debug.pyi b/typings/distutils-stubs/debug.pyi new file mode 100644 index 0000000000..30095883b0 --- /dev/null +++ b/typings/distutils-stubs/debug.pyi @@ -0,0 +1,3 @@ +from typing import Final + +DEBUG: Final[str | None] diff --git a/typings/distutils-stubs/dep_util.pyi b/typings/distutils-stubs/dep_util.pyi new file mode 100644 index 0000000000..058377acca --- /dev/null +++ b/typings/distutils-stubs/dep_util.pyi @@ -0,0 +1,14 @@ +from _typeshed import StrOrBytesPath, SupportsLenAndGetItem +from collections.abc import Iterable +from typing import Literal, TypeVar + +_SourcesT = TypeVar("_SourcesT", bound=StrOrBytesPath) +_TargetsT = TypeVar("_TargetsT", bound=StrOrBytesPath) + +def newer(source: StrOrBytesPath, target: StrOrBytesPath) -> bool | Literal[1]: ... +def newer_pairwise( + sources: SupportsLenAndGetItem[_SourcesT], targets: SupportsLenAndGetItem[_TargetsT] +) -> tuple[list[_SourcesT], list[_TargetsT]]: ... +def newer_group( + sources: Iterable[StrOrBytesPath], target: StrOrBytesPath, missing: Literal["error", "ignore", "newer"] = "error" +) -> Literal[0, 1]: ... diff --git a/typings/distutils-stubs/dir_util.pyi b/typings/distutils-stubs/dir_util.pyi new file mode 100644 index 0000000000..23e2c3bc28 --- /dev/null +++ b/typings/distutils-stubs/dir_util.pyi @@ -0,0 +1,23 @@ +from _typeshed import StrOrBytesPath, StrPath +from collections.abc import Iterable +from typing import Literal + +def mkpath(name: str, mode: int = 0o777, verbose: bool | Literal[0, 1] = 1, dry_run: bool | Literal[0, 1] = 0) -> list[str]: ... +def create_tree( + base_dir: StrPath, + files: Iterable[StrPath], + mode: int = 0o777, + verbose: bool | Literal[0, 1] = 1, + dry_run: bool | Literal[0, 1] = 0, +) -> None: ... +def copy_tree( + src: StrPath, + dst: str, + preserve_mode: bool | Literal[0, 1] = 1, + preserve_times: bool | Literal[0, 1] = 1, + preserve_symlinks: bool | Literal[0, 1] = 0, + update: bool | Literal[0, 1] = 0, + verbose: bool | Literal[0, 1] = 1, + dry_run: bool | Literal[0, 1] = 0, +) -> list[str]: ... +def remove_tree(directory: StrOrBytesPath, verbose: bool | Literal[0, 1] = 1, dry_run: bool | Literal[0, 1] = 0) -> None: ... diff --git a/typings/distutils-stubs/dist.pyi b/typings/distutils-stubs/dist.pyi new file mode 100644 index 0000000000..75fc7dbb38 --- /dev/null +++ b/typings/distutils-stubs/dist.pyi @@ -0,0 +1,317 @@ +from _typeshed import Incomplete, StrOrBytesPath, StrPath, SupportsWrite +from collections.abc import Iterable, MutableMapping +from distutils.cmd import Command +from distutils.command.bdist import bdist +from distutils.command.bdist_dumb import bdist_dumb +from distutils.command.bdist_rpm import bdist_rpm +from distutils.command.build import build +from distutils.command.build_clib import build_clib +from distutils.command.build_ext import build_ext +from distutils.command.build_py import build_py +from distutils.command.build_scripts import build_scripts +from distutils.command.check import check +from distutils.command.clean import clean +from distutils.command.config import config +from distutils.command.install import install +from distutils.command.install_data import install_data +from distutils.command.install_egg_info import install_egg_info +from distutils.command.install_headers import install_headers +from distutils.command.install_lib import install_lib +from distutils.command.install_scripts import install_scripts +from distutils.command.register import register +from distutils.command.sdist import sdist +from distutils.command.upload import upload +from re import Pattern +from typing import IO, ClassVar, Literal, TypeVar, overload +from typing_extensions import TypeAlias + +command_re: Pattern[str] + +_OptionsList: TypeAlias = list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] +_CommandT = TypeVar("_CommandT", bound=Command) + +class DistributionMetadata: + def __init__(self, path: StrOrBytesPath | None = None) -> None: ... + name: str | None + version: str | None + author: str | None + author_email: str | None + maintainer: str | None + maintainer_email: str | None + url: str | None + license: str | None + description: str | None + long_description: str | None + keywords: str | list[str] | None + platforms: str | list[str] | None + classifiers: str | list[str] | None + download_url: str | None + provides: list[str] | None + requires: list[str] | None + obsoletes: list[str] | None + def read_pkg_file(self, file: IO[str]) -> None: ... + def write_pkg_info(self, base_dir: StrPath) -> None: ... + def write_pkg_file(self, file: SupportsWrite[str]) -> None: ... + def get_name(self) -> str: ... + def get_version(self) -> str: ... + def get_fullname(self) -> str: ... + def get_author(self) -> str: ... + def get_author_email(self) -> str: ... + def get_maintainer(self) -> str: ... + def get_maintainer_email(self) -> str: ... + def get_contact(self) -> str: ... + def get_contact_email(self) -> str: ... + def get_url(self) -> str: ... + def get_license(self) -> str: ... + def get_licence(self) -> str: ... + def get_description(self) -> str: ... + def get_long_description(self) -> str: ... + def get_keywords(self) -> str | list[str]: ... + def get_platforms(self) -> str | list[str]: ... + def get_classifiers(self) -> str | list[str]: ... + def get_download_url(self) -> str: ... + def get_requires(self) -> list[str]: ... + def set_requires(self, value: Iterable[str]) -> None: ... + def get_provides(self) -> list[str]: ... + def set_provides(self, value: Iterable[str]) -> None: ... + def get_obsoletes(self) -> list[str]: ... + def set_obsoletes(self, value: Iterable[str]) -> None: ... + +class Distribution: + cmdclass: dict[str, type[Command]] + metadata: DistributionMetadata + 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: ... + global_options: ClassVar[_OptionsList] + common_usage: ClassVar[str] + display_options: ClassVar[_OptionsList] + display_option_names: ClassVar[list[str]] + negative_opt: ClassVar[dict[str, str]] + verbose: Literal[0, 1] + dry_run: Literal[0, 1] + help: Literal[0, 1] + command_packages: list[str] | None + script_name: str | None + script_args: list[str] | None + command_options: dict[str, dict[str, tuple[str, str]]] + dist_files: list[tuple[str, str, str]] + packages: Incomplete + package_data: dict[str, list[str]] + package_dir: Incomplete + py_modules: Incomplete + libraries: Incomplete + headers: Incomplete + ext_modules: Incomplete + ext_package: Incomplete + include_dirs: Incomplete + extra_path: Incomplete + scripts: Incomplete + data_files: Incomplete + password: str + command_obj: Incomplete + have_run: Incomplete + want_user_cfg: bool + def dump_option_dicts( + self, header: Incomplete | None = None, commands: Incomplete | None = None, indent: str = "" + ) -> None: ... + def find_config_files(self): ... + commands: Incomplete + def parse_command_line(self): ... + def finalize_options(self) -> None: ... + def handle_display_options(self, option_order): ... + def print_command_list(self, commands, header, max_length) -> None: ... + def print_commands(self) -> None: ... + def get_command_list(self): ... + def get_command_packages(self): ... + # NOTE: This list comes directly from the distutils/command folder. Minus bdist_msi and bdist_wininst. + @overload + def get_command_obj(self, command: Literal["bdist"], create: Literal[1, True] = 1) -> bdist: ... + @overload + def get_command_obj(self, command: Literal["bdist_dumb"], create: Literal[1, True] = 1) -> bdist_dumb: ... + @overload + def get_command_obj(self, command: Literal["bdist_rpm"], create: Literal[1, True] = 1) -> bdist_rpm: ... + @overload + def get_command_obj(self, command: Literal["build"], create: Literal[1, True] = 1) -> build: ... + @overload + def get_command_obj(self, command: Literal["build_clib"], create: Literal[1, True] = 1) -> build_clib: ... + @overload + def get_command_obj(self, command: Literal["build_ext"], create: Literal[1, True] = 1) -> build_ext: ... + @overload + def get_command_obj(self, command: Literal["build_py"], create: Literal[1, True] = 1) -> build_py: ... + @overload + def get_command_obj(self, command: Literal["build_scripts"], create: Literal[1, True] = 1) -> build_scripts: ... + @overload + def get_command_obj(self, command: Literal["check"], create: Literal[1, True] = 1) -> check: ... + @overload + def get_command_obj(self, command: Literal["clean"], create: Literal[1, True] = 1) -> clean: ... + @overload + def get_command_obj(self, command: Literal["config"], create: Literal[1, True] = 1) -> config: ... + @overload + def get_command_obj(self, command: Literal["install"], create: Literal[1, True] = 1) -> install: ... + @overload + def get_command_obj(self, command: Literal["install_data"], create: Literal[1, True] = 1) -> install_data: ... + @overload + def get_command_obj(self, command: Literal["install_egg_info"], create: Literal[1, True] = 1) -> install_egg_info: ... + @overload + def get_command_obj(self, command: Literal["install_headers"], create: Literal[1, True] = 1) -> install_headers: ... + @overload + def get_command_obj(self, command: Literal["install_lib"], create: Literal[1, True] = 1) -> install_lib: ... + @overload + def get_command_obj(self, command: Literal["install_scripts"], create: Literal[1, True] = 1) -> install_scripts: ... + @overload + def get_command_obj(self, command: Literal["register"], create: Literal[1, True] = 1) -> register: ... + @overload + def get_command_obj(self, command: Literal["sdist"], create: Literal[1, True] = 1) -> sdist: ... + @overload + def get_command_obj(self, command: Literal["upload"], create: Literal[1, True] = 1) -> upload: ... + @overload + def get_command_obj(self, command: str, create: Literal[1, True] = 1) -> Command: ... + # Not replicating the overloads for "Command | None", user may use "isinstance" + @overload + def get_command_obj(self, command: str, create: Literal[0, False]) -> Command | None: ... + @overload + def get_command_class(self, command: Literal["bdist"]) -> type[bdist]: ... + @overload + def get_command_class(self, command: Literal["bdist_dumb"]) -> type[bdist_dumb]: ... + @overload + def get_command_class(self, command: Literal["bdist_rpm"]) -> type[bdist_rpm]: ... + @overload + def get_command_class(self, command: Literal["build"]) -> type[build]: ... + @overload + def get_command_class(self, command: Literal["build_clib"]) -> type[build_clib]: ... + @overload + def get_command_class(self, command: Literal["build_ext"]) -> type[build_ext]: ... + @overload + def get_command_class(self, command: Literal["build_py"]) -> type[build_py]: ... + @overload + def get_command_class(self, command: Literal["build_scripts"]) -> type[build_scripts]: ... + @overload + def get_command_class(self, command: Literal["check"]) -> type[check]: ... + @overload + def get_command_class(self, command: Literal["clean"]) -> type[clean]: ... + @overload + def get_command_class(self, command: Literal["config"]) -> type[config]: ... + @overload + def get_command_class(self, command: Literal["install"]) -> type[install]: ... + @overload + def get_command_class(self, command: Literal["install_data"]) -> type[install_data]: ... + @overload + def get_command_class(self, command: Literal["install_egg_info"]) -> type[install_egg_info]: ... + @overload + def get_command_class(self, command: Literal["install_headers"]) -> type[install_headers]: ... + @overload + def get_command_class(self, command: Literal["install_lib"]) -> type[install_lib]: ... + @overload + def get_command_class(self, command: Literal["install_scripts"]) -> type[install_scripts]: ... + @overload + def get_command_class(self, command: Literal["register"]) -> type[register]: ... + @overload + def get_command_class(self, command: Literal["sdist"]) -> type[sdist]: ... + @overload + def get_command_class(self, command: Literal["upload"]) -> type[upload]: ... + @overload + def get_command_class(self, command: str) -> type[Command]: ... + @overload + def reinitialize_command(self, command: Literal["bdist"], reinit_subcommands: bool = False) -> bdist: ... + @overload + def reinitialize_command(self, command: Literal["bdist_dumb"], reinit_subcommands: bool = False) -> bdist_dumb: ... + @overload + def reinitialize_command(self, command: Literal["bdist_rpm"], reinit_subcommands: bool = False) -> bdist_rpm: ... + @overload + def reinitialize_command(self, command: Literal["build"], reinit_subcommands: bool = False) -> build: ... + @overload + def reinitialize_command(self, command: Literal["build_clib"], reinit_subcommands: bool = False) -> build_clib: ... + @overload + def reinitialize_command(self, command: Literal["build_ext"], reinit_subcommands: bool = False) -> build_ext: ... + @overload + def reinitialize_command(self, command: Literal["build_py"], reinit_subcommands: bool = False) -> build_py: ... + @overload + def reinitialize_command(self, command: Literal["build_scripts"], reinit_subcommands: bool = False) -> build_scripts: ... + @overload + def reinitialize_command(self, command: Literal["check"], reinit_subcommands: bool = False) -> check: ... + @overload + def reinitialize_command(self, command: Literal["clean"], reinit_subcommands: bool = False) -> clean: ... + @overload + def reinitialize_command(self, command: Literal["config"], reinit_subcommands: bool = False) -> config: ... + @overload + def reinitialize_command(self, command: Literal["install"], reinit_subcommands: bool = False) -> install: ... + @overload + def reinitialize_command(self, command: Literal["install_data"], reinit_subcommands: bool = False) -> install_data: ... + @overload + def reinitialize_command( + self, command: Literal["install_egg_info"], reinit_subcommands: bool = False + ) -> install_egg_info: ... + @overload + def reinitialize_command(self, command: Literal["install_headers"], reinit_subcommands: bool = False) -> install_headers: ... + @overload + def reinitialize_command(self, command: Literal["install_lib"], reinit_subcommands: bool = False) -> install_lib: ... + @overload + def reinitialize_command(self, command: Literal["install_scripts"], reinit_subcommands: bool = False) -> install_scripts: ... + @overload + def reinitialize_command(self, command: Literal["register"], reinit_subcommands: bool = False) -> register: ... + @overload + def reinitialize_command(self, command: Literal["sdist"], reinit_subcommands: bool = False) -> sdist: ... + @overload + def reinitialize_command(self, command: Literal["upload"], reinit_subcommands: bool = False) -> upload: ... + @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 announce(self, msg, level: int = 2) -> None: ... + def run_commands(self) -> None: ... + def run_command(self, command: str) -> None: ... + def has_pure_modules(self) -> bool: ... + def has_ext_modules(self) -> bool: ... + def has_c_libraries(self) -> bool: ... + def has_modules(self) -> bool: ... + def has_headers(self) -> bool: ... + def has_scripts(self) -> bool: ... + def has_data_files(self) -> bool: ... + def is_pure(self) -> bool: ... + + # Default getter methods generated in __init__ from self.metadata._METHOD_BASENAMES + def get_name(self) -> str: ... + def get_version(self) -> str: ... + def get_fullname(self) -> str: ... + def get_author(self) -> str: ... + def get_author_email(self) -> str: ... + def get_maintainer(self) -> str: ... + def get_maintainer_email(self) -> str: ... + def get_contact(self) -> str: ... + def get_contact_email(self) -> str: ... + def get_url(self) -> str: ... + def get_license(self) -> str: ... + def get_licence(self) -> str: ... + def get_description(self) -> str: ... + def get_long_description(self) -> str: ... + def get_keywords(self) -> str | list[str]: ... + def get_platforms(self) -> str | list[str]: ... + def get_classifiers(self) -> str | list[str]: ... + def get_download_url(self) -> str: ... + def get_requires(self) -> list[str]: ... + def get_provides(self) -> list[str]: ... + def get_obsoletes(self) -> list[str]: ... + + # Default attributes generated in __init__ from self.display_option_names + help_commands: bool | Literal[0] + name: str | Literal[0] + version: str | Literal[0] + fullname: str | Literal[0] + author: str | Literal[0] + author_email: str | Literal[0] + maintainer: str | Literal[0] + maintainer_email: str | Literal[0] + contact: str | Literal[0] + contact_email: str | Literal[0] + url: str | Literal[0] + license: str | Literal[0] + licence: str | Literal[0] + description: str | Literal[0] + long_description: str | Literal[0] + platforms: str | list[str] | Literal[0] + classifiers: str | list[str] | Literal[0] + keywords: str | list[str] | Literal[0] + provides: list[str] | Literal[0] + requires: list[str] | Literal[0] + obsoletes: list[str] | Literal[0] diff --git a/typings/distutils-stubs/errors.pyi b/typings/distutils-stubs/errors.pyi new file mode 100644 index 0000000000..e483362bfb --- /dev/null +++ b/typings/distutils-stubs/errors.pyi @@ -0,0 +1,19 @@ +class DistutilsError(Exception): ... +class DistutilsModuleError(DistutilsError): ... +class DistutilsClassError(DistutilsError): ... +class DistutilsGetoptError(DistutilsError): ... +class DistutilsArgError(DistutilsError): ... +class DistutilsFileError(DistutilsError): ... +class DistutilsOptionError(DistutilsError): ... +class DistutilsSetupError(DistutilsError): ... +class DistutilsPlatformError(DistutilsError): ... +class DistutilsExecError(DistutilsError): ... +class DistutilsInternalError(DistutilsError): ... +class DistutilsTemplateError(DistutilsError): ... +class DistutilsByteCompileError(DistutilsError): ... +class CCompilerError(Exception): ... +class PreprocessError(CCompilerError): ... +class CompileError(CCompilerError): ... +class LibError(CCompilerError): ... +class LinkError(CCompilerError): ... +class UnknownFileError(CCompilerError): ... diff --git a/typings/distutils-stubs/extension.pyi b/typings/distutils-stubs/extension.pyi new file mode 100644 index 0000000000..789bbf6ec3 --- /dev/null +++ b/typings/distutils-stubs/extension.pyi @@ -0,0 +1,36 @@ +class Extension: + name: str + sources: list[str] + include_dirs: list[str] + define_macros: list[tuple[str, str | None]] + undef_macros: list[str] + library_dirs: list[str] + libraries: list[str] + runtime_library_dirs: list[str] + extra_objects: list[str] + extra_compile_args: list[str] + extra_link_args: list[str] + export_symbols: list[str] + swig_opts: list[str] + depends: list[str] + language: str | None + optional: bool | None + def __init__( + self, + name: str, + sources: list[str], + include_dirs: list[str] | None = None, + define_macros: list[tuple[str, str | None]] | None = None, + undef_macros: list[str] | None = None, + library_dirs: list[str] | None = None, + libraries: list[str] | None = None, + runtime_library_dirs: list[str] | None = None, + extra_objects: list[str] | None = None, + extra_compile_args: list[str] | None = None, + extra_link_args: list[str] | None = None, + export_symbols: list[str] | None = None, + swig_opts: list[str] | None = None, + depends: list[str] | None = None, + language: str | None = None, + optional: bool | None = None, + ) -> None: ... diff --git a/typings/distutils-stubs/fancy_getopt.pyi b/typings/distutils-stubs/fancy_getopt.pyi new file mode 100644 index 0000000000..c4d37419ed --- /dev/null +++ b/typings/distutils-stubs/fancy_getopt.pyi @@ -0,0 +1,34 @@ +from collections.abc import Iterable, Mapping +from re import Pattern +from typing import Any, Final, overload +from typing_extensions import TypeAlias + +_Option: TypeAlias = tuple[str, str | None, str] +_GR: TypeAlias = tuple[list[str], OptionDummy] + +longopt_pat: Final = r"[a-zA-Z](?:[a-zA-Z0-9-]*)" +longopt_re: Final[Pattern[str]] +neg_alias_re: Final[Pattern[str]] +longopt_xlate: Final[dict[int, int]] + +class FancyGetopt: + def __init__(self, option_table: list[_Option] | None = None) -> None: ... + # TODO kinda wrong, `getopt(object=object())` is invalid + @overload + def getopt(self, args: list[str] | None = None) -> _GR: ... + @overload + def getopt(self, args: list[str] | None, object: Any) -> list[str]: ... + def get_option_order(self) -> list[tuple[str, str]]: ... + def generate_help(self, header: str | None = None) -> list[str]: ... + +def fancy_getopt( + options: list[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: list[str] | None +) -> list[str] | _GR: ... + +WS_TRANS: Final[dict[int, str]] + +def wrap_text(text: str, width: int) -> list[str]: ... +def translate_longopt(opt: str) -> str: ... + +class OptionDummy: + def __init__(self, options: Iterable[str] = []) -> None: ... diff --git a/typings/distutils-stubs/file_util.pyi b/typings/distutils-stubs/file_util.pyi new file mode 100644 index 0000000000..873d23ea7e --- /dev/null +++ b/typings/distutils-stubs/file_util.pyi @@ -0,0 +1,38 @@ +from _typeshed import BytesPath, StrOrBytesPath, StrPath +from collections.abc import Iterable +from typing import Literal, TypeVar, overload + +_StrPathT = TypeVar("_StrPathT", bound=StrPath) +_BytesPathT = TypeVar("_BytesPathT", bound=BytesPath) + +@overload +def copy_file( + src: StrPath, + dst: _StrPathT, + preserve_mode: bool | Literal[0, 1] = 1, + preserve_times: bool | Literal[0, 1] = 1, + update: bool | Literal[0, 1] = 0, + link: str | None = None, + verbose: bool | Literal[0, 1] = 1, + dry_run: bool | Literal[0, 1] = 0, +) -> tuple[_StrPathT | str, bool]: ... +@overload +def copy_file( + src: BytesPath, + dst: _BytesPathT, + preserve_mode: bool | Literal[0, 1] = 1, + preserve_times: bool | Literal[0, 1] = 1, + update: bool | Literal[0, 1] = 0, + link: str | None = None, + verbose: bool | Literal[0, 1] = 1, + dry_run: bool | Literal[0, 1] = 0, +) -> tuple[_BytesPathT | bytes, bool]: ... +@overload +def move_file( + src: StrPath, dst: _StrPathT, verbose: bool | Literal[0, 1] = 0, dry_run: bool | Literal[0, 1] = 0 +) -> _StrPathT | str: ... +@overload +def move_file( + src: BytesPath, dst: _BytesPathT, verbose: bool | Literal[0, 1] = 0, dry_run: bool | Literal[0, 1] = 0 +) -> _BytesPathT | bytes: ... +def write_file(filename: StrOrBytesPath, contents: Iterable[str]) -> None: ... diff --git a/typings/distutils-stubs/filelist.pyi b/typings/distutils-stubs/filelist.pyi new file mode 100644 index 0000000000..607a78a1fb --- /dev/null +++ b/typings/distutils-stubs/filelist.pyi @@ -0,0 +1,58 @@ +from collections.abc import Iterable +from re import Pattern +from typing import Literal, overload + +# class is entirely undocumented +class FileList: + allfiles: Iterable[str] | None + files: list[str] + def __init__(self, warn: None = None, debug_print: None = None) -> None: ... + def set_allfiles(self, allfiles: Iterable[str]) -> None: ... + def findall(self, dir: str = ".") -> None: ... + def debug_print(self, msg: str) -> None: ... + def append(self, item: str) -> None: ... + def extend(self, items: Iterable[str]) -> None: ... + def sort(self) -> None: ... + def remove_duplicates(self) -> None: ... + def process_template_line(self, line: str) -> None: ... + @overload + def include_pattern( + self, pattern: str, anchor: bool | Literal[0, 1] = 1, prefix: str | None = None, is_regex: Literal[0, False] = 0 + ) -> bool: ... + @overload + def include_pattern(self, pattern: str | Pattern[str], *, is_regex: Literal[True, 1]) -> bool: ... + @overload + def include_pattern( + self, + pattern: str | Pattern[str], + anchor: bool | Literal[0, 1] = 1, + prefix: str | None = None, + is_regex: bool | Literal[0, 1] = 0, + ) -> bool: ... + @overload + def exclude_pattern( + self, pattern: str, anchor: bool | Literal[0, 1] = 1, prefix: str | None = None, is_regex: Literal[0, False] = 0 + ) -> bool: ... + @overload + def exclude_pattern(self, pattern: str | Pattern[str], *, is_regex: Literal[True, 1]) -> bool: ... + @overload + def exclude_pattern( + self, + pattern: str | Pattern[str], + anchor: bool | Literal[0, 1] = 1, + prefix: str | None = None, + is_regex: bool | Literal[0, 1] = 0, + ) -> bool: ... + +def findall(dir: str = ".") -> list[str]: ... +def glob_to_re(pattern: str) -> str: ... +@overload +def translate_pattern( + pattern: str, anchor: bool | Literal[0, 1] = 1, prefix: str | None = None, is_regex: Literal[False, 0] = 0 +) -> Pattern[str]: ... +@overload +def translate_pattern(pattern: str | Pattern[str], *, is_regex: Literal[True, 1]) -> Pattern[str]: ... +@overload +def translate_pattern( + pattern: str | Pattern[str], anchor: bool | Literal[0, 1] = 1, prefix: str | None = None, is_regex: bool | Literal[0, 1] = 0 +) -> Pattern[str]: ... diff --git a/typings/distutils-stubs/log.pyi b/typings/distutils-stubs/log.pyi new file mode 100644 index 0000000000..0ea135c283 --- /dev/null +++ b/typings/distutils-stubs/log.pyi @@ -0,0 +1,25 @@ +from typing import Any, Final + +DEBUG: Final = 1 +INFO: Final = 2 +WARN: Final = 3 +ERROR: Final = 4 +FATAL: Final = 5 + +class Log: + def __init__(self, threshold: int = 3) -> None: ... + def log(self, level: int, msg: str, *args: Any) -> None: ... + def debug(self, msg: str, *args: Any) -> None: ... + def info(self, msg: str, *args: Any) -> None: ... + def warn(self, msg: str, *args: Any) -> None: ... + def error(self, msg: str, *args: Any) -> None: ... + def fatal(self, msg: str, *args: Any) -> None: ... + +def log(level: int, msg: str, *args: Any) -> None: ... +def debug(msg: str, *args: Any) -> None: ... +def info(msg: str, *args: Any) -> None: ... +def warn(msg: str, *args: Any) -> None: ... +def error(msg: str, *args: Any) -> None: ... +def fatal(msg: str, *args: Any) -> None: ... +def set_threshold(level: int) -> int: ... +def set_verbosity(v: int) -> None: ... diff --git a/typings/distutils-stubs/msvccompiler.pyi b/typings/distutils-stubs/msvccompiler.pyi new file mode 100644 index 0000000000..80872a6b73 --- /dev/null +++ b/typings/distutils-stubs/msvccompiler.pyi @@ -0,0 +1,3 @@ +from distutils.ccompiler import CCompiler + +class MSVCCompiler(CCompiler): ... diff --git a/typings/distutils-stubs/spawn.pyi b/typings/distutils-stubs/spawn.pyi new file mode 100644 index 0000000000..50d89aeb9e --- /dev/null +++ b/typings/distutils-stubs/spawn.pyi @@ -0,0 +1,6 @@ +from typing import Literal + +def spawn( + cmd: list[str], search_path: bool | Literal[0, 1] = 1, verbose: bool | Literal[0, 1] = 0, dry_run: bool | Literal[0, 1] = 0 +) -> None: ... +def find_executable(executable: str, path: str | None = None) -> str | None: ... diff --git a/typings/distutils-stubs/sysconfig.pyi b/typings/distutils-stubs/sysconfig.pyi new file mode 100644 index 0000000000..4a9c45eb56 --- /dev/null +++ b/typings/distutils-stubs/sysconfig.pyi @@ -0,0 +1,33 @@ +import sys +from collections.abc import Mapping +from distutils.ccompiler import CCompiler +from typing import Final, Literal, overload +from typing_extensions import deprecated + +PREFIX: Final[str] +EXEC_PREFIX: Final[str] +BASE_PREFIX: Final[str] +BASE_EXEC_PREFIX: Final[str] +project_base: Final[str] +python_build: Final[bool] + +def expand_makefile_vars(s: str, vars: Mapping[str, str]) -> str: ... +@overload +@deprecated("SO is deprecated, use EXT_SUFFIX. Support is removed in Python 3.11") +def get_config_var(name: Literal["SO"]) -> int | str | None: ... +@overload +def get_config_var(name: str) -> int | str | None: ... +@overload +def get_config_vars() -> dict[str, str | int]: ... +@overload +def get_config_vars(arg: str, /, *args: str) -> list[str | int]: ... +def get_config_h_filename() -> str: ... +def get_makefile_filename() -> str: ... +def get_python_inc(plat_specific: bool | Literal[0, 1] = 0, prefix: str | None = None) -> str: ... +def get_python_lib( + plat_specific: bool | Literal[0, 1] = 0, standard_lib: bool | Literal[0, 1] = 0, prefix: str | None = None +) -> str: ... +def customize_compiler(compiler: CCompiler) -> None: ... + +if sys.version_info < (3, 10): + def get_python_version() -> str: ... diff --git a/typings/distutils-stubs/text_file.pyi b/typings/distutils-stubs/text_file.pyi new file mode 100644 index 0000000000..54951af7e5 --- /dev/null +++ b/typings/distutils-stubs/text_file.pyi @@ -0,0 +1,21 @@ +from typing import IO, Literal + +class TextFile: + def __init__( + self, + filename: str | None = None, + file: IO[str] | None = None, + *, + strip_comments: bool | Literal[0, 1] = ..., + lstrip_ws: bool | Literal[0, 1] = ..., + rstrip_ws: bool | Literal[0, 1] = ..., + skip_blanks: bool | Literal[0, 1] = ..., + join_lines: bool | Literal[0, 1] = ..., + collapse_join: bool | Literal[0, 1] = ..., + ) -> None: ... + def open(self, filename: str) -> None: ... + def close(self) -> None: ... + def warn(self, msg: str, line: list[int] | tuple[int, int] | int | None = None) -> None: ... + def readline(self) -> str | None: ... + def readlines(self) -> list[str]: ... + def unreadline(self, line: str) -> str: ... diff --git a/typings/distutils-stubs/unixccompiler.pyi b/typings/distutils-stubs/unixccompiler.pyi new file mode 100644 index 0000000000..e1d443471a --- /dev/null +++ b/typings/distutils-stubs/unixccompiler.pyi @@ -0,0 +1,3 @@ +from distutils.ccompiler import CCompiler + +class UnixCCompiler(CCompiler): ... diff --git a/typings/distutils-stubs/util.pyi b/typings/distutils-stubs/util.pyi new file mode 100644 index 0000000000..0e1bb4165d --- /dev/null +++ b/typings/distutils-stubs/util.pyi @@ -0,0 +1,53 @@ +from _typeshed import StrPath, Unused +from collections.abc import Callable, Container, Iterable, Mapping +from typing import Any, Literal +from typing_extensions import TypeVarTuple, Unpack + +_Ts = TypeVarTuple("_Ts") + +def get_host_platform() -> str: ... +def get_platform() -> str: ... +def convert_path(pathname: str) -> str: ... +def change_root(new_root: StrPath, pathname: StrPath) -> str: ... +def check_environ() -> None: ... +def subst_vars(s: str, local_vars: Mapping[str, str]) -> None: ... +def split_quoted(s: str) -> list[str]: ... +def execute( + func: Callable[[Unpack[_Ts]], Unused], + args: tuple[Unpack[_Ts]], + msg: str | None = None, + verbose: bool | Literal[0, 1] = 0, + dry_run: bool | Literal[0, 1] = 0, +) -> None: ... +def strtobool(val: str) -> Literal[0, 1]: ... +def byte_compile( + py_files: list[str], + optimize: int = 0, + force: bool | Literal[0, 1] = 0, + prefix: str | None = None, + base_dir: str | None = None, + verbose: bool | Literal[0, 1] = 1, + dry_run: bool | Literal[0, 1] = 0, + direct: bool | None = None, +) -> None: ... +def rfc822_escape(header: str) -> str: ... +def run_2to3( + files: Iterable[str], + fixer_names: Iterable[str] | None = None, + options: Mapping[str, Any] | None = None, + explicit: Unused = None, +) -> None: ... +def copydir_run_2to3( + src: StrPath, + dest: StrPath, + template: str | None = None, + fixer_names: Iterable[str] | None = None, + options: Mapping[str, Any] | None = None, + explicit: Container[str] | None = None, +) -> list[str]: ... + +class Mixin2to3: + fixer_names: Iterable[str] | None + options: Mapping[str, Any] | None + explicit: Container[str] | None + def run_2to3(self, files: Iterable[str]) -> None: ... diff --git a/typings/distutils-stubs/version.pyi b/typings/distutils-stubs/version.pyi new file mode 100644 index 0000000000..47da65ef87 --- /dev/null +++ b/typings/distutils-stubs/version.pyi @@ -0,0 +1,36 @@ +from abc import abstractmethod +from re import Pattern +from typing_extensions import Self + +class Version: + def __eq__(self, other: object) -> bool: ... + def __lt__(self, other: Self | str) -> bool: ... + def __le__(self, other: Self | str) -> bool: ... + def __gt__(self, other: Self | str) -> bool: ... + def __ge__(self, other: Self | str) -> bool: ... + @abstractmethod + def __init__(self, vstring: str | None = None) -> None: ... + @abstractmethod + def parse(self, vstring: str) -> Self: ... + @abstractmethod + def __str__(self) -> str: ... + @abstractmethod + def _cmp(self, other: Self | str) -> bool: ... + +class StrictVersion(Version): + version_re: Pattern[str] + version: tuple[int, int, int] + prerelease: tuple[str, int] | None + def __init__(self, vstring: str | None = None) -> None: ... + def parse(self, vstring: str) -> Self: ... + def __str__(self) -> str: ... # noqa: Y029 + def _cmp(self, other: Self | str) -> bool: ... + +class LooseVersion(Version): + component_re: Pattern[str] + vstring: str + version: tuple[str | int, ...] + def __init__(self, vstring: str | None = None) -> None: ... + def parse(self, vstring: str) -> Self: ... + def __str__(self) -> str: ... # noqa: Y029 + def _cmp(self, other: Self | str) -> bool: ... From ed1d086797cfd866158c5f48875f7f25c667b6ff Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 17 Oct 2024 17:25:37 -0400 Subject: [PATCH 3/6] Merge setuptools/_distutils from typeshed --- typings/distutils-stubs/_modified.pyi | 17 +++ typings/distutils-stubs/archive_util.pyi | 16 +-- typings/distutils-stubs/ccompiler.pyi | 42 ++++--- typings/distutils-stubs/cmd.pyi | 116 +++++++++--------- typings/distutils-stubs/command/__init__.pyi | 7 -- typings/distutils-stubs/command/bdist.pyi | 23 ++-- typings/distutils-stubs/command/bdist_msi.pyi | 45 ------- typings/distutils-stubs/command/bdist_rpm.pyi | 71 +++++------ .../distutils-stubs/command/bdist_wininst.pyi | 16 --- typings/distutils-stubs/command/build.pyi | 26 ++-- .../distutils-stubs/command/build_clib.pyi | 22 ++-- typings/distutils-stubs/command/build_ext.pyi | 55 ++++----- typings/distutils-stubs/command/build_py.pyi | 27 ++-- typings/distutils-stubs/command/install.pyi | 55 ++++----- .../distutils-stubs/command/install_lib.pyi | 17 ++- .../command/install_scripts.pyi | 11 +- typings/distutils-stubs/command/sdist.pyi | 29 ++--- typings/distutils-stubs/compat/__init__.pyi | 1 + typings/distutils-stubs/dep_util.pyi | 15 +-- typings/distutils-stubs/dist.pyi | 100 +++++++-------- typings/distutils-stubs/filelist.pyi | 32 +---- typings/distutils-stubs/sysconfig.pyi | 21 +--- typings/distutils-stubs/util.pyi | 43 +++---- 23 files changed, 343 insertions(+), 464 deletions(-) create mode 100644 typings/distutils-stubs/_modified.pyi delete mode 100644 typings/distutils-stubs/command/bdist_msi.pyi delete mode 100644 typings/distutils-stubs/command/bdist_wininst.pyi create mode 100644 typings/distutils-stubs/compat/__init__.pyi diff --git a/typings/distutils-stubs/_modified.pyi b/typings/distutils-stubs/_modified.pyi new file mode 100644 index 0000000000..e825ba0db5 --- /dev/null +++ b/typings/distutils-stubs/_modified.pyi @@ -0,0 +1,17 @@ +from _typeshed import StrOrBytesPath +from collections.abc import Callable, Iterable +from typing import Literal, TypeVar + +_SourcesT = TypeVar("_SourcesT", bound=StrOrBytesPath) +_TargetsT = TypeVar("_TargetsT", bound=StrOrBytesPath) + +def newer(source: StrOrBytesPath, target: StrOrBytesPath) -> bool: ... +def newer_pairwise( + sources: Iterable[_SourcesT], targets: Iterable[_TargetsT], newer: Callable[[_SourcesT, _TargetsT], bool] = newer +) -> tuple[list[_SourcesT], list[_TargetsT]]: ... +def newer_group( + sources: Iterable[StrOrBytesPath], target: StrOrBytesPath, missing: Literal["error", "ignore", "newer"] = "error" +) -> bool: ... +def newer_pairwise_group( + sources: Iterable[_SourcesT], targets: Iterable[_TargetsT], *, newer: Callable[[_SourcesT, _TargetsT], bool] = newer +) -> tuple[list[_SourcesT], list[_TargetsT]]: ... diff --git a/typings/distutils-stubs/archive_util.pyi b/typings/distutils-stubs/archive_util.pyi index 16684ff069..c2b9566e12 100644 --- a/typings/distutils-stubs/archive_util.pyi +++ b/typings/distutils-stubs/archive_util.pyi @@ -7,8 +7,8 @@ def make_archive( format: str, root_dir: StrOrBytesPath | None = None, base_dir: str | None = None, - verbose: bool | Literal[0, 1] = 0, - dry_run: bool | Literal[0, 1] = 0, + verbose: bool = False, + dry_run: bool = False, owner: str | None = None, group: str | None = None, ) -> str: ... @@ -18,18 +18,18 @@ def make_archive( format: str, root_dir: StrOrBytesPath, base_dir: str | None = None, - verbose: bool | Literal[0, 1] = 0, - dry_run: bool | Literal[0, 1] = 0, + verbose: bool = False, + dry_run: bool = False, owner: str | None = None, group: str | None = None, ) -> str: ... def make_tarball( base_name: str, base_dir: StrPath, - compress: str | None = "gzip", - verbose: bool | Literal[0, 1] = 0, - dry_run: bool | Literal[0, 1] = 0, + compress: Literal["gzip", "bzip2", "xz"] | None = "gzip", + verbose: bool = False, + dry_run: bool = False, owner: str | None = None, group: str | None = None, ) -> str: ... -def make_zipfile(base_name: str, base_dir: str, verbose: bool | Literal[0, 1] = 0, dry_run: bool | Literal[0, 1] = 0) -> str: ... +def make_zipfile(base_name: str, base_dir: str, verbose: bool = False, dry_run: bool = False) -> str: ... diff --git a/typings/distutils-stubs/ccompiler.pyi b/typings/distutils-stubs/ccompiler.pyi index e0f33f430e..465b9c977e 100644 --- a/typings/distutils-stubs/ccompiler.pyi +++ b/typings/distutils-stubs/ccompiler.pyi @@ -1,10 +1,11 @@ from _typeshed import BytesPath, StrPath, Unused from collections.abc import Callable, Iterable -from distutils.file_util import _BytesPathT, _StrPathT -from typing import Literal, overload +from typing import ClassVar, Literal, TypeVar, overload from typing_extensions import TypeAlias, TypeVarTuple, Unpack _Macro: TypeAlias = tuple[str] | tuple[str, str | None] +_StrPathT = TypeVar("_StrPathT", bound=StrPath) +_BytesPathT = TypeVar("_BytesPathT", bound=BytesPath) _Ts = TypeVarTuple("_Ts") def gen_lib_options( @@ -13,15 +14,20 @@ def gen_lib_options( def gen_preprocess_options(macros: list[_Macro], include_dirs: list[str]) -> list[str]: ... def get_default_compiler(osname: str | None = None, platform: str | None = None) -> str: ... def new_compiler( - plat: str | None = None, - compiler: str | None = None, - verbose: bool | Literal[0, 1] = 0, - dry_run: bool | Literal[0, 1] = 0, - force: bool | Literal[0, 1] = 0, + plat: str | None = None, compiler: str | None = None, verbose: bool = False, dry_run: bool = False, force: bool = False ) -> CCompiler: ... def show_compilers() -> None: ... class CCompiler: + src_extensions: ClassVar[list[str] | None] + obj_extension: ClassVar[str | None] + static_lib_extension: ClassVar[str | None] + shared_lib_extension: ClassVar[str | None] + static_lib_format: ClassVar[str | None] + shared_lib_format: ClassVar[str | None] + exe_extension: ClassVar[str | None] + language_map: ClassVar[dict[str, str]] + language_order: ClassVar[list[str]] dry_run: bool force: bool verbose: bool @@ -32,9 +38,7 @@ class CCompiler: library_dirs: list[str] runtime_library_dirs: list[str] objects: list[str] - def __init__( - self, verbose: bool | Literal[0, 1] = 0, dry_run: bool | Literal[0, 1] = 0, force: bool | Literal[0, 1] = 0 - ) -> None: ... + def __init__(self, verbose: bool = False, dry_run: bool = False, force: bool = False) -> None: ... def add_include_dir(self, dir: str) -> None: ... def set_include_dirs(self, dirs: list[str]) -> None: ... def add_library(self, libname: str) -> None: ... @@ -48,7 +52,7 @@ class CCompiler: def add_link_object(self, object: str) -> None: ... def set_link_objects(self, objects: list[str]) -> None: ... def detect_language(self, sources: str | list[str]) -> str | None: ... - def find_library_file(self, dirs: list[str], lib: str, debug: bool | Literal[0, 1] = 0) -> str | None: ... + def find_library_file(self, dirs: list[str], lib: str, debug: bool = False) -> str | None: ... def has_function( self, funcname: str, @@ -67,7 +71,7 @@ class CCompiler: output_dir: str | None = None, macros: list[_Macro] | None = None, include_dirs: list[str] | None = None, - debug: bool | Literal[0, 1] = 0, + debug: bool = False, extra_preargs: list[str] | None = None, extra_postargs: list[str] | None = None, depends: list[str] | None = None, @@ -77,7 +81,7 @@ class CCompiler: objects: list[str], output_libname: str, output_dir: str | None = None, - debug: bool | Literal[0, 1] = 0, + debug: bool = False, target_lang: str | None = None, ) -> None: ... def link( @@ -90,7 +94,7 @@ class CCompiler: library_dirs: list[str] | None = None, runtime_library_dirs: list[str] | None = None, export_symbols: list[str] | None = None, - debug: bool | Literal[0, 1] = 0, + debug: bool = False, extra_preargs: list[str] | None = None, extra_postargs: list[str] | None = None, build_temp: str | None = None, @@ -104,7 +108,7 @@ class CCompiler: libraries: list[str] | None = None, library_dirs: list[str] | None = None, runtime_library_dirs: list[str] | None = None, - debug: bool | Literal[0, 1] = 0, + debug: bool = False, extra_preargs: list[str] | None = None, extra_postargs: list[str] | None = None, target_lang: str | None = None, @@ -118,7 +122,7 @@ class CCompiler: library_dirs: list[str] | None = None, runtime_library_dirs: list[str] | None = None, export_symbols: list[str] | None = None, - debug: bool | Literal[0, 1] = 0, + debug: bool = False, extra_preargs: list[str] | None = None, extra_postargs: list[str] | None = None, build_temp: str | None = None, @@ -133,7 +137,7 @@ class CCompiler: library_dirs: list[str] | None = None, runtime_library_dirs: list[str] | None = None, export_symbols: list[str] | None = None, - debug: bool | Literal[0, 1] = 0, + debug: bool = False, extra_preargs: list[str] | None = None, extra_postargs: list[str] | None = None, build_temp: str | None = None, @@ -153,10 +157,10 @@ class CCompiler: @overload def executable_filename(self, basename: StrPath, strip_dir: Literal[1, True], output_dir: StrPath = "") -> str: ... def library_filename( - self, libname: str, lib_type: str = "static", strip_dir: bool | Literal[0, 1] = 0, output_dir: StrPath = "" + self, libname: str, lib_type: str = "static", strip_dir: bool = False, output_dir: StrPath = "" ) -> str: ... def object_filenames( - self, source_filenames: Iterable[StrPath], strip_dir: bool | Literal[0, 1] = 0, output_dir: StrPath | None = "" + self, source_filenames: Iterable[StrPath], strip_dir: bool = False, output_dir: StrPath | None = None ) -> list[str]: ... @overload def shared_object_filename(self, basename: str, strip_dir: Literal[0, False] = 0, output_dir: StrPath = "") -> str: ... diff --git a/typings/distutils-stubs/cmd.pyi b/typings/distutils-stubs/cmd.pyi index dcb423a49b..fb9cc06b03 100644 --- a/typings/distutils-stubs/cmd.pyi +++ b/typings/distutils-stubs/cmd.pyi @@ -1,6 +1,7 @@ -from _typeshed import BytesPath, Incomplete, StrOrBytesPath, StrPath, Unused +from _typeshed import BytesPath, StrOrBytesPath, StrPath, Unused from abc import abstractmethod from collections.abc import Callable, Iterable +from typing import Any, ClassVar, TypeVar, overload from distutils.command.bdist import bdist from distutils.command.bdist_dumb import bdist_dumb from distutils.command.bdist_rpm import bdist_rpm @@ -26,22 +27,27 @@ from distutils.file_util import _BytesPathT, _StrPathT from typing import Any, ClassVar, Literal, TypeVar, overload from typing_extensions import TypeVarTuple, Unpack +from .dist import Distribution + +_StrPathT = TypeVar("_StrPathT", bound=StrPath) +_BytesPathT = TypeVar("_BytesPathT", bound=BytesPath) _CommandT = TypeVar("_CommandT", bound=Command) _Ts = TypeVarTuple("_Ts") class Command: - dry_run: Literal[0, 1] # Exposed from __getattr_. Same as Distribution.dry_run + dry_run: bool # Exposed from __getattr_. Same as Distribution.dry_run distribution: Distribution # Any to work around variance issues sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]] def __init__(self, dist: Distribution) -> None: ... + def ensure_finalized(self) -> None: ... @abstractmethod def initialize_options(self) -> None: ... @abstractmethod def finalize_options(self) -> None: ... @abstractmethod def run(self) -> None: ... - def announce(self, msg: str, level: int = 1) -> None: ... + def announce(self, msg: str, level: int = 10) -> None: ... def debug_print(self, msg: str) -> None: ... def ensure_string(self, option: str, default: str | None = None) -> None: ... def ensure_string_list(self, option: str) -> None: ... @@ -51,109 +57,109 @@ class Command: def set_undefined_options(self, src_cmd: str, *option_pairs: tuple[str, str]) -> None: ... # NOTE: This list comes directly from the distutils/command folder. Minus bdist_msi and bdist_wininst. @overload - def get_finalized_command(self, command: Literal["bdist"], create: bool | Literal[0, 1] = 1) -> bdist: ... + def get_finalized_command(self, command: Literal["bdist"], create: bool = True) -> bdist: ... @overload - def get_finalized_command(self, command: Literal["bdist_dumb"], create: bool | Literal[0, 1] = 1) -> bdist_dumb: ... + def get_finalized_command(self, command: Literal["bdist_dumb"], create: bool = True) -> bdist_dumb: ... @overload - def get_finalized_command(self, command: Literal["bdist_rpm"], create: bool | Literal[0, 1] = 1) -> bdist_rpm: ... + def get_finalized_command(self, command: Literal["bdist_rpm"], create: bool = True) -> bdist_rpm: ... @overload - def get_finalized_command(self, command: Literal["build"], create: bool | Literal[0, 1] = 1) -> build: ... + def get_finalized_command(self, command: Literal["build"], create: bool = True) -> build: ... @overload - def get_finalized_command(self, command: Literal["build_clib"], create: bool | Literal[0, 1] = 1) -> build_clib: ... + def get_finalized_command(self, command: Literal["build_clib"], create: bool = True) -> build_clib: ... @overload - def get_finalized_command(self, command: Literal["build_ext"], create: bool | Literal[0, 1] = 1) -> build_ext: ... + def get_finalized_command(self, command: Literal["build_ext"], create: bool = True) -> build_ext: ... @overload - def get_finalized_command(self, command: Literal["build_py"], create: bool | Literal[0, 1] = 1) -> build_py: ... + def get_finalized_command(self, command: Literal["build_py"], create: bool = True) -> build_py: ... @overload - def get_finalized_command(self, command: Literal["build_scripts"], create: bool | Literal[0, 1] = 1) -> build_scripts: ... + def get_finalized_command(self, command: Literal["build_scripts"], create: bool = True) -> build_scripts: ... @overload - def get_finalized_command(self, command: Literal["check"], create: bool | Literal[0, 1] = 1) -> check: ... + def get_finalized_command(self, command: Literal["check"], create: bool = True) -> check: ... @overload - def get_finalized_command(self, command: Literal["clean"], create: bool | Literal[0, 1] = 1) -> clean: ... + def get_finalized_command(self, command: Literal["clean"], create: bool = True) -> clean: ... @overload - def get_finalized_command(self, command: Literal["config"], create: bool | Literal[0, 1] = 1) -> config: ... + def get_finalized_command(self, command: Literal["config"], create: bool = True) -> config: ... @overload - def get_finalized_command(self, command: Literal["install"], create: bool | Literal[0, 1] = 1) -> install: ... + def get_finalized_command(self, command: Literal["install"], create: bool = True) -> install: ... @overload - def get_finalized_command(self, command: Literal["install_data"], create: bool | Literal[0, 1] = 1) -> install_data: ... + def get_finalized_command(self, command: Literal["install_data"], create: bool = True) -> install_data: ... @overload def get_finalized_command( - self, command: Literal["install_egg_info"], create: bool | Literal[0, 1] = 1 + self, command: Literal["install_egg_info"], create: bool = True ) -> install_egg_info: ... @overload - def get_finalized_command(self, command: Literal["install_headers"], create: bool | Literal[0, 1] = 1) -> install_headers: ... + def get_finalized_command(self, command: Literal["install_headers"], create: bool = True) -> install_headers: ... @overload - def get_finalized_command(self, command: Literal["install_lib"], create: bool | Literal[0, 1] = 1) -> install_lib: ... + def get_finalized_command(self, command: Literal["install_lib"], create: bool = True) -> install_lib: ... @overload - def get_finalized_command(self, command: Literal["install_scripts"], create: bool | Literal[0, 1] = 1) -> install_scripts: ... + def get_finalized_command(self, command: Literal["install_scripts"], create: bool = True) -> install_scripts: ... @overload - def get_finalized_command(self, command: Literal["register"], create: bool | Literal[0, 1] = 1) -> register: ... + def get_finalized_command(self, command: Literal["register"], create: bool = True) -> register: ... @overload - def get_finalized_command(self, command: Literal["sdist"], create: bool | Literal[0, 1] = 1) -> sdist: ... + def get_finalized_command(self, command: Literal["sdist"], create: bool = True) -> sdist: ... @overload - def get_finalized_command(self, command: Literal["upload"], create: bool | Literal[0, 1] = 1) -> upload: ... + def get_finalized_command(self, command: Literal["upload"], create: bool = True) -> upload: ... @overload - def get_finalized_command(self, command: str, create: bool | Literal[0, 1] = 1) -> Command: ... + def get_finalized_command(self, command: str, create: bool = True) -> Command: ... @overload - def reinitialize_command(self, command: Literal["bdist"], reinit_subcommands: bool | Literal[0, 1] = 0) -> bdist: ... + def reinitialize_command(self, command: Literal["bdist"], reinit_subcommands: bool = False) -> bdist: ... @overload def reinitialize_command( - self, command: Literal["bdist_dumb"], reinit_subcommands: bool | Literal[0, 1] = 0 + self, command: Literal["bdist_dumb"], reinit_subcommands: bool = False ) -> bdist_dumb: ... @overload - def reinitialize_command(self, command: Literal["bdist_rpm"], reinit_subcommands: bool | Literal[0, 1] = 0) -> bdist_rpm: ... + def reinitialize_command(self, command: Literal["bdist_rpm"], reinit_subcommands: bool = False) -> bdist_rpm: ... @overload - def reinitialize_command(self, command: Literal["build"], reinit_subcommands: bool | Literal[0, 1] = 0) -> build: ... + def reinitialize_command(self, command: Literal["build"], reinit_subcommands: bool = False) -> build: ... @overload def reinitialize_command( - self, command: Literal["build_clib"], reinit_subcommands: bool | Literal[0, 1] = 0 + self, command: Literal["build_clib"], reinit_subcommands: bool = False ) -> build_clib: ... @overload - def reinitialize_command(self, command: Literal["build_ext"], reinit_subcommands: bool | Literal[0, 1] = 0) -> build_ext: ... + def reinitialize_command(self, command: Literal["build_ext"], reinit_subcommands: bool = False) -> build_ext: ... @overload - def reinitialize_command(self, command: Literal["build_py"], reinit_subcommands: bool | Literal[0, 1] = 0) -> build_py: ... + def reinitialize_command(self, command: Literal["build_py"], reinit_subcommands: bool = False) -> build_py: ... @overload def reinitialize_command( - self, command: Literal["build_scripts"], reinit_subcommands: bool | Literal[0, 1] = 0 + self, command: Literal["build_scripts"], reinit_subcommands: bool = False ) -> build_scripts: ... @overload - def reinitialize_command(self, command: Literal["check"], reinit_subcommands: bool | Literal[0, 1] = 0) -> check: ... + def reinitialize_command(self, command: Literal["check"], reinit_subcommands: bool = False) -> check: ... @overload - def reinitialize_command(self, command: Literal["clean"], reinit_subcommands: bool | Literal[0, 1] = 0) -> clean: ... + def reinitialize_command(self, command: Literal["clean"], reinit_subcommands: bool = False) -> clean: ... @overload - def reinitialize_command(self, command: Literal["config"], reinit_subcommands: bool | Literal[0, 1] = 0) -> config: ... + def reinitialize_command(self, command: Literal["config"], reinit_subcommands: bool = False) -> config: ... @overload - def reinitialize_command(self, command: Literal["install"], reinit_subcommands: bool | Literal[0, 1] = 0) -> install: ... + def reinitialize_command(self, command: Literal["install"], reinit_subcommands: bool = False) -> install: ... @overload def reinitialize_command( - self, command: Literal["install_data"], reinit_subcommands: bool | Literal[0, 1] = 0 + self, command: Literal["install_data"], reinit_subcommands: bool = False ) -> install_data: ... @overload def reinitialize_command( - self, command: Literal["install_egg_info"], reinit_subcommands: bool | Literal[0, 1] = 0 + self, command: Literal["install_egg_info"], reinit_subcommands: bool = False ) -> install_egg_info: ... @overload def reinitialize_command( - self, command: Literal["install_headers"], reinit_subcommands: bool | Literal[0, 1] = 0 + self, command: Literal["install_headers"], reinit_subcommands: bool = False ) -> install_headers: ... @overload def reinitialize_command( - self, command: Literal["install_lib"], reinit_subcommands: bool | Literal[0, 1] = 0 + self, command: Literal["install_lib"], reinit_subcommands: bool = False ) -> install_lib: ... @overload def reinitialize_command( - self, command: Literal["install_scripts"], reinit_subcommands: bool | Literal[0, 1] = 0 + self, command: Literal["install_scripts"], reinit_subcommands: bool = False ) -> install_scripts: ... @overload - def reinitialize_command(self, command: Literal["register"], reinit_subcommands: bool | Literal[0, 1] = 0) -> register: ... + def reinitialize_command(self, command: Literal["register"], reinit_subcommands: bool = False) -> register: ... @overload - def reinitialize_command(self, command: Literal["sdist"], reinit_subcommands: bool | Literal[0, 1] = 0) -> sdist: ... + def reinitialize_command(self, command: Literal["sdist"], reinit_subcommands: bool = False) -> sdist: ... @overload - def reinitialize_command(self, command: Literal["upload"], reinit_subcommands: bool | Literal[0, 1] = 0) -> upload: ... + def reinitialize_command(self, command: Literal["upload"], reinit_subcommands: bool = False) -> upload: ... @overload - def reinitialize_command(self, command: str, reinit_subcommands: bool | Literal[0, 1] = 0) -> Command: ... + def reinitialize_command(self, command: str, reinit_subcommands: bool = False) -> Command: ... @overload - def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool | Literal[0, 1] = 0) -> _CommandT: ... + 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: ... @@ -166,8 +172,8 @@ class Command: self, infile: StrPath, outfile: _StrPathT, - preserve_mode: bool | Literal[0, 1] = 1, - preserve_times: bool | Literal[0, 1] = 1, + preserve_mode: bool = True, + preserve_times: bool = True, link: str | None = None, level: Unused = 1, ) -> tuple[_StrPathT | str, bool]: ... @@ -176,8 +182,8 @@ class Command: self, infile: BytesPath, outfile: _BytesPathT, - preserve_mode: bool | Literal[0, 1] = 1, - preserve_times: bool | Literal[0, 1] = 1, + preserve_mode: bool = True, + preserve_times: bool = True, link: str | None = None, level: Unused = 1, ) -> tuple[_BytesPathT | bytes, bool]: ... @@ -185,16 +191,16 @@ class Command: self, infile: StrPath, outfile: str, - preserve_mode: bool | Literal[0, 1] = 1, - preserve_times: bool | Literal[0, 1] = 1, - preserve_symlinks: bool | Literal[0, 1] = 0, + preserve_mode: bool = True, + preserve_times: bool = True, + preserve_symlinks: bool = False, level: Unused = 1, ) -> list[str]: ... @overload def move_file(self, src: StrPath, dst: _StrPathT, level: Unused = 1) -> _StrPathT | str: ... @overload def move_file(self, src: BytesPath, dst: _BytesPathT, level: Unused = 1) -> _BytesPathT | bytes: ... - def spawn(self, cmd: Iterable[str], search_path: bool | Literal[0, 1] = 1, level: Unused = 1) -> None: ... + def spawn(self, cmd: Iterable[str], search_path: bool = True, level: Unused = 1) -> None: ... @overload def make_archive( self, @@ -225,5 +231,3 @@ class Command: skip_msg: str | None = None, level: Unused = 1, ) -> None: ... - def ensure_finalized(self) -> None: ... - def dump_options(self, header: Incomplete | None = None, indent: str = "") -> None: ... diff --git a/typings/distutils-stubs/command/__init__.pyi b/typings/distutils-stubs/command/__init__.pyi index 4d7372858a..856c5eb8b4 100644 --- a/typings/distutils-stubs/command/__init__.pyi +++ b/typings/distutils-stubs/command/__init__.pyi @@ -1,5 +1,3 @@ -import sys - from . import ( bdist, bdist_dumb, @@ -41,8 +39,3 @@ __all__ = [ "check", "upload", ] - -if sys.version_info < (3, 10): - from . import bdist_wininst - - __all__ += ["bdist_wininst"] diff --git a/typings/distutils-stubs/command/bdist.pyi b/typings/distutils-stubs/command/bdist.pyi index 43d77087f7..0d69929831 100644 --- a/typings/distutils-stubs/command/bdist.pyi +++ b/typings/distutils-stubs/command/bdist.pyi @@ -1,27 +1,26 @@ from _typeshed import Unused from collections.abc import Callable -from typing import Any, ClassVar +from typing import ClassVar +from typing_extensions import deprecated from ..cmd import Command def show_formats() -> None: ... +class ListCompat(dict[str, tuple[str, str]]): + @deprecated("format_commands is now a dict. append is deprecated") + def append(self, item: Unused) -> None: ... + class bdist(Command): - description: str - user_options: ClassVar[list[tuple[str, str | None, str]]] + description: ClassVar[str] + 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, ...]] default_format: ClassVar[dict[str, str]] - format_commands: ClassVar[list[str]] - format_command: ClassVar[dict[str, tuple[str, str]]] - bdist_base: Any - plat_name: Any - formats: Any - dist_dir: Any - skip_build: int - group: Any - owner: Any + format_commands: ClassVar[ListCompat] + format_command = format_commands + def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... def run(self) -> None: ... diff --git a/typings/distutils-stubs/command/bdist_msi.pyi b/typings/distutils-stubs/command/bdist_msi.pyi deleted file mode 100644 index d0eac1a3be..0000000000 --- a/typings/distutils-stubs/command/bdist_msi.pyi +++ /dev/null @@ -1,45 +0,0 @@ -import sys -from typing import Any, ClassVar, Literal - -from ..cmd import Command - -if sys.platform == "win32": - from msilib import Dialog - - class PyDialog(Dialog): - def __init__(self, *args, **kw) -> None: ... - def title(self, title) -> None: ... - def back(self, title, next, name: str = "Back", active: bool | Literal[0, 1] = 1): ... - def cancel(self, title, next, name: str = "Cancel", active: bool | Literal[0, 1] = 1): ... - def next(self, title, next, name: str = "Next", active: bool | Literal[0, 1] = 1): ... - def xbutton(self, name, title, next, xpos): ... - - class bdist_msi(Command): - description: str - user_options: ClassVar[list[tuple[str, str | None, str]]] - boolean_options: ClassVar[list[str]] - all_versions: Any - other_version: str - if sys.version_info >= (3, 9): - def __init__(self, *args, **kw) -> None: ... - bdist_dir: Any - plat_name: Any - keep_temp: int - no_target_compile: int - no_target_optimize: int - target_version: Any - dist_dir: Any - skip_build: Any - install_script: Any - pre_install_script: Any - versions: Any - def initialize_options(self) -> None: ... - install_script_key: Any - def finalize_options(self) -> None: ... - db: Any - def run(self) -> None: ... - def add_files(self) -> None: ... - def add_find_python(self) -> None: ... - def add_scripts(self) -> None: ... - def add_ui(self) -> None: ... - def get_installer_filename(self, fullname): ... diff --git a/typings/distutils-stubs/command/bdist_rpm.pyi b/typings/distutils-stubs/command/bdist_rpm.pyi index 89c43e1b97..83b4161094 100644 --- a/typings/distutils-stubs/command/bdist_rpm.pyi +++ b/typings/distutils-stubs/command/bdist_rpm.pyi @@ -1,4 +1,5 @@ -from typing import Any, ClassVar +from _typeshed import Incomplete +from typing import ClassVar from ..cmd import Command @@ -7,44 +8,44 @@ class bdist_rpm(Command): user_options: ClassVar[list[tuple[str, str | None, str]]] boolean_options: ClassVar[list[str]] negative_opt: ClassVar[dict[str, str]] - bdist_base: Any - rpm_base: Any - dist_dir: Any - python: Any - fix_python: Any - spec_only: Any - binary_only: Any - source_only: Any - use_bzip2: Any - distribution_name: Any - group: Any - release: Any - serial: Any - vendor: Any - packager: Any - doc_files: Any - changelog: Any - icon: Any - prep_script: Any - build_script: Any - install_script: Any - clean_script: Any - verify_script: Any - pre_install: Any - post_install: Any - pre_uninstall: Any - post_uninstall: Any - prep: Any - provides: Any - requires: Any - conflicts: Any - build_requires: Any - obsoletes: Any + bdist_base: Incomplete + rpm_base: Incomplete + dist_dir: Incomplete + python: Incomplete + fix_python: Incomplete + spec_only: Incomplete + binary_only: Incomplete + source_only: Incomplete + use_bzip2: Incomplete + distribution_name: Incomplete + group: Incomplete + release: Incomplete + serial: Incomplete + vendor: Incomplete + packager: Incomplete + doc_files: Incomplete + changelog: Incomplete + icon: Incomplete + prep_script: Incomplete + build_script: Incomplete + install_script: Incomplete + clean_script: Incomplete + verify_script: Incomplete + pre_install: Incomplete + post_install: Incomplete + pre_uninstall: Incomplete + post_uninstall: Incomplete + prep: Incomplete + provides: Incomplete + requires: Incomplete + conflicts: Incomplete + build_requires: Incomplete + obsoletes: Incomplete keep_temp: int use_rpm_opt_flags: int rpm3_mode: int no_autoreq: int - force_arch: Any + force_arch: Incomplete quiet: int def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... diff --git a/typings/distutils-stubs/command/bdist_wininst.pyi b/typings/distutils-stubs/command/bdist_wininst.pyi deleted file mode 100644 index cf333bc540..0000000000 --- a/typings/distutils-stubs/command/bdist_wininst.pyi +++ /dev/null @@ -1,16 +0,0 @@ -from _typeshed import StrOrBytesPath -from distutils.cmd import Command -from typing import ClassVar - -class bdist_wininst(Command): - description: ClassVar[str] - user_options: ClassVar[list[tuple[str, str | None, str]]] - boolean_options: ClassVar[list[str]] - - def initialize_options(self) -> None: ... - def finalize_options(self) -> None: ... - def run(self) -> None: ... - def get_inidata(self) -> str: ... - def create_exe(self, arcname: StrOrBytesPath, fullname: str, bitmap: StrOrBytesPath | None = None) -> None: ... - def get_installer_filename(self, fullname: str) -> str: ... - def get_exe_bytes(self) -> bytes: ... diff --git a/typings/distutils-stubs/command/build.pyi b/typings/distutils-stubs/command/build.pyi index 78ba6b7042..a1c00b5c81 100644 --- a/typings/distutils-stubs/command/build.pyi +++ b/typings/distutils-stubs/command/build.pyi @@ -1,6 +1,6 @@ -from _typeshed import Unused +from _typeshed import Incomplete, Unused from collections.abc import Callable -from typing import Any, ClassVar +from typing import ClassVar from ..cmd import Command @@ -12,17 +12,17 @@ class build(Command): boolean_options: ClassVar[list[str]] help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], Unused]]]] build_base: str - build_purelib: Any - build_platlib: Any - build_lib: Any - build_temp: Any - build_scripts: Any - compiler: Any - plat_name: Any - debug: Any + build_purelib: Incomplete + build_platlib: Incomplete + build_lib: Incomplete + build_temp: Incomplete + build_scripts: Incomplete + compiler: Incomplete + plat_name: Incomplete + debug: Incomplete force: int - executable: Any - parallel: Any + executable: Incomplete + parallel: Incomplete def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... def run(self) -> None: ... @@ -30,5 +30,3 @@ class build(Command): def has_c_libraries(self): ... def has_ext_modules(self): ... def has_scripts(self): ... - # Any to work around variance issues - sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]] diff --git a/typings/distutils-stubs/command/build_clib.pyi b/typings/distutils-stubs/command/build_clib.pyi index 1f66e2efc2..687cb53450 100644 --- a/typings/distutils-stubs/command/build_clib.pyi +++ b/typings/distutils-stubs/command/build_clib.pyi @@ -1,25 +1,23 @@ -from _typeshed import Unused +from _typeshed import Incomplete, Unused from collections.abc import Callable -from typing import Any, ClassVar +from typing import ClassVar from ..cmd import Command -def show_compilers() -> None: ... - class build_clib(Command): description: str user_options: ClassVar[list[tuple[str, str, str]]] boolean_options: ClassVar[list[str]] help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], Unused]]]] - build_clib: Any - build_temp: Any - libraries: Any - include_dirs: Any - define: Any - undef: Any - debug: Any + build_clib: Incomplete + build_temp: Incomplete + libraries: Incomplete + include_dirs: Incomplete + define: Incomplete + undef: Incomplete + debug: Incomplete force: int - compiler: Any + compiler: Incomplete def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... def run(self) -> None: ... diff --git a/typings/distutils-stubs/command/build_ext.pyi b/typings/distutils-stubs/command/build_ext.pyi index a0813c3140..49c7f19485 100644 --- a/typings/distutils-stubs/command/build_ext.pyi +++ b/typings/distutils-stubs/command/build_ext.pyi @@ -1,40 +1,37 @@ -from _typeshed import Unused +from _typeshed import Incomplete, Unused from collections.abc import Callable -from typing import Any, ClassVar +from typing import ClassVar from ..cmd import Command - -extension_name_re: Any - -def show_compilers() -> None: ... +from ..extension import Extension class build_ext(Command): description: str - sep_by: Any + sep_by: Incomplete user_options: ClassVar[list[tuple[str, str | None, str]]] boolean_options: ClassVar[list[str]] help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], Unused]]]] - extensions: Any - build_lib: Any - plat_name: Any - build_temp: Any + extensions: Incomplete + build_lib: Incomplete + plat_name: Incomplete + build_temp: Incomplete inplace: int - package: Any - include_dirs: Any - define: Any - undef: Any - libraries: Any - library_dirs: Any - rpath: Any - link_objects: Any - debug: Any - force: Any - compiler: Any - swig: Any - swig_cpp: Any - swig_opts: Any - user: Any - parallel: Any + package: Incomplete + include_dirs: Incomplete + define: Incomplete + undef: Incomplete + libraries: Incomplete + library_dirs: Incomplete + rpath: Incomplete + link_objects: Incomplete + debug: Incomplete + force: Incomplete + compiler: Incomplete + swig: Incomplete + swig_cpp: Incomplete + swig_opts: Incomplete + user: Incomplete + parallel: Incomplete def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... def run(self) -> None: ... @@ -48,5 +45,5 @@ class build_ext(Command): def get_ext_fullpath(self, ext_name: str) -> str: ... def get_ext_fullname(self, ext_name: str) -> str: ... def get_ext_filename(self, ext_name: str) -> str: ... - def get_export_symbols(self, ext): ... - def get_libraries(self, ext): ... + def get_export_symbols(self, ext: Extension) -> list[str]: ... + def get_libraries(self, ext: Extension) -> list[str]: ... diff --git a/typings/distutils-stubs/command/build_py.pyi b/typings/distutils-stubs/command/build_py.pyi index 90f0675141..67515b9bf0 100644 --- a/typings/distutils-stubs/command/build_py.pyi +++ b/typings/distutils-stubs/command/build_py.pyi @@ -1,24 +1,24 @@ -from typing import Any, ClassVar, Literal +from _typeshed import Incomplete +from typing import ClassVar from ..cmd import Command -from ..util import Mixin2to3 as Mixin2to3 class build_py(Command): description: str user_options: ClassVar[list[tuple[str, str | None, str]]] boolean_options: ClassVar[list[str]] negative_opt: ClassVar[dict[str, str]] - build_lib: Any - py_modules: Any - package: Any - package_data: Any - package_dir: Any + build_lib: Incomplete + py_modules: Incomplete + package: Incomplete + package_data: Incomplete + package_dir: Incomplete compile: int optimize: int - force: Any + force: Incomplete def initialize_options(self) -> None: ... - packages: Any - data_files: Any + packages: Incomplete + data_files: Incomplete def finalize_options(self) -> None: ... def run(self) -> None: ... def get_data_files(self): ... @@ -32,13 +32,8 @@ class build_py(Command): def find_all_modules(self): ... def get_source_files(self): ... def get_module_outfile(self, build_dir, package, module): ... - def get_outputs(self, include_bytecode: bool | Literal[0, 1] = 1): ... + def get_outputs(self, include_bytecode: bool = True): ... def build_module(self, module, module_file, package): ... def build_modules(self) -> None: ... def build_packages(self) -> None: ... def byte_compile(self, files) -> None: ... - -class build_py_2to3(build_py, Mixin2to3): - updated_files: Any - def run(self) -> None: ... - def build_module(self, module, module_file, package): ... diff --git a/typings/distutils-stubs/command/install.pyi b/typings/distutils-stubs/command/install.pyi index 24a4eff2fb..8e092f7d6c 100644 --- a/typings/distutils-stubs/command/install.pyi +++ b/typings/distutils-stubs/command/install.pyi @@ -1,50 +1,41 @@ -import sys -from collections.abc import Callable -from typing import Any, ClassVar, Final, Literal +from _typeshed import Incomplete +from typing import ClassVar from ..cmd import Command -HAS_USER_SITE: Final[bool] - -SCHEME_KEYS: Final[tuple[Literal["purelib"], Literal["platlib"], Literal["headers"], Literal["scripts"], Literal["data"]]] -INSTALL_SCHEMES: Final[dict[str, dict[str, str]]] - -if sys.version_info < (3, 10): - WINDOWS_SCHEME: Final[dict[str, str]] - class install(Command): description: str user_options: ClassVar[list[tuple[str, str | None, str]]] boolean_options: ClassVar[list[str]] negative_opt: ClassVar[dict[str, str]] prefix: str | None - exec_prefix: Any + exec_prefix: Incomplete home: str | None user: bool - install_base: Any - install_platbase: Any + install_base: Incomplete + install_platbase: Incomplete root: str | None - install_purelib: Any - install_platlib: Any - install_headers: Any + install_purelib: Incomplete + install_platlib: Incomplete + install_headers: Incomplete install_lib: str | None - install_scripts: Any - install_data: Any - install_userbase: Any - install_usersite: Any - compile: Any - optimize: Any - extra_path: Any + install_scripts: Incomplete + install_data: Incomplete + install_userbase: Incomplete + install_usersite: Incomplete + compile: Incomplete + optimize: Incomplete + extra_path: Incomplete install_path_file: int force: int skip_build: int warn_dir: int - build_base: Any - build_lib: Any - record: Any + build_base: Incomplete + build_lib: Incomplete + record: Incomplete def initialize_options(self) -> None: ... - config_vars: Any - install_libbase: Any + config_vars: Incomplete + install_libbase: Incomplete def finalize_options(self) -> None: ... def dump_dirs(self, msg) -> None: ... def finalize_unix(self) -> None: ... @@ -53,8 +44,8 @@ class install(Command): def expand_basedirs(self) -> None: ... def expand_dirs(self) -> None: ... def convert_paths(self, *names) -> None: ... - path_file: Any - extra_dirs: Any + path_file: Incomplete + extra_dirs: Incomplete def handle_extra_path(self) -> None: ... def change_roots(self, *names) -> None: ... def create_home_path(self) -> None: ... @@ -66,5 +57,3 @@ class install(Command): def has_headers(self): ... def has_scripts(self): ... def has_data(self): ... - # Any to work around variance issues - sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]] diff --git a/typings/distutils-stubs/command/install_lib.pyi b/typings/distutils-stubs/command/install_lib.pyi index 149ecae897..7edc148be9 100644 --- a/typings/distutils-stubs/command/install_lib.pyi +++ b/typings/distutils-stubs/command/install_lib.pyi @@ -1,25 +1,24 @@ -from typing import Any, ClassVar, Final +from _typeshed import Incomplete +from typing import ClassVar from ..cmd import Command -PYTHON_SOURCE_EXTENSION: Final = ".py" - class install_lib(Command): description: str user_options: ClassVar[list[tuple[str, str | None, str]]] boolean_options: ClassVar[list[str]] negative_opt: ClassVar[dict[str, str]] - install_dir: Any - build_dir: Any + install_dir: Incomplete + build_dir: Incomplete force: int - compile: Any - optimize: Any - skip_build: Any + compile: Incomplete + optimize: Incomplete + skip_build: Incomplete def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... def run(self) -> None: ... def build(self) -> None: ... - def install(self): ... + def install(self) -> list[str]: ... def byte_compile(self, files) -> None: ... def get_outputs(self): ... def get_inputs(self): ... diff --git a/typings/distutils-stubs/command/install_scripts.pyi b/typings/distutils-stubs/command/install_scripts.pyi index 5ee5589ad3..b9eab32f9d 100644 --- a/typings/distutils-stubs/command/install_scripts.pyi +++ b/typings/distutils-stubs/command/install_scripts.pyi @@ -1,4 +1,5 @@ -from typing import Any, ClassVar +from _typeshed import Incomplete +from typing import ClassVar from ..cmd import Command @@ -6,13 +7,13 @@ class install_scripts(Command): description: str user_options: ClassVar[list[tuple[str, str | None, str]]] boolean_options: ClassVar[list[str]] - install_dir: Any + install_dir: Incomplete force: int - build_dir: Any - skip_build: Any + build_dir: Incomplete + skip_build: Incomplete def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... - outfiles: Any + outfiles: list[str] def run(self) -> None: ... def get_inputs(self): ... def get_outputs(self): ... diff --git a/typings/distutils-stubs/command/sdist.pyi b/typings/distutils-stubs/command/sdist.pyi index 5b7fe24195..a84fbef2a6 100644 --- a/typings/distutils-stubs/command/sdist.pyi +++ b/typings/distutils-stubs/command/sdist.pyi @@ -1,39 +1,38 @@ -from _typeshed import Unused +from _typeshed import Incomplete, Unused from collections.abc import Callable -from typing import Any, ClassVar +from typing import ClassVar from ..cmd import Command def show_formats() -> None: ... class sdist(Command): - description: str + description: ClassVar[str] + def checking_metadata(self): ... + user_options: ClassVar[list[tuple[str, str | None, str]]] boolean_options: ClassVar[list[str]] help_options: ClassVar[list[tuple[str, str | None, str, Callable[[], Unused]]]] negative_opt: ClassVar[dict[str, str]] - # Any to work around variance issues - sub_commands: ClassVar[list[tuple[str, Callable[[Any], bool] | None]]] READMES: ClassVar[tuple[str, ...]] - template: Any - manifest: Any + template: Incomplete + manifest: Incomplete use_defaults: int prune: int manifest_only: int force_manifest: int - formats: Any + formats: Incomplete keep_temp: int - dist_dir: Any - archive_files: Any + dist_dir: Incomplete + archive_files: Incomplete metadata_check: int - owner: Any - group: Any + owner: Incomplete + group: Incomplete def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... - filelist: Any + filelist: Incomplete def run(self) -> None: ... - def check_metadata(self) -> None: ... def get_file_list(self) -> None: ... def add_defaults(self) -> None: ... def read_template(self) -> None: ... @@ -43,3 +42,5 @@ class sdist(Command): def make_release_tree(self, base_dir, files) -> None: ... def make_distribution(self) -> None: ... def get_archive_files(self): ... + +def is_comment(line: str) -> bool: ... diff --git a/typings/distutils-stubs/compat/__init__.pyi b/typings/distutils-stubs/compat/__init__.pyi new file mode 100644 index 0000000000..39acc295d7 --- /dev/null +++ b/typings/distutils-stubs/compat/__init__.pyi @@ -0,0 +1 @@ +def consolidate_linker_args(args: list[str]) -> str | list[str]: ... diff --git a/typings/distutils-stubs/dep_util.pyi b/typings/distutils-stubs/dep_util.pyi index 058377acca..88cd92f001 100644 --- a/typings/distutils-stubs/dep_util.pyi +++ b/typings/distutils-stubs/dep_util.pyi @@ -1,14 +1 @@ -from _typeshed import StrOrBytesPath, SupportsLenAndGetItem -from collections.abc import Iterable -from typing import Literal, TypeVar - -_SourcesT = TypeVar("_SourcesT", bound=StrOrBytesPath) -_TargetsT = TypeVar("_TargetsT", bound=StrOrBytesPath) - -def newer(source: StrOrBytesPath, target: StrOrBytesPath) -> bool | Literal[1]: ... -def newer_pairwise( - sources: SupportsLenAndGetItem[_SourcesT], targets: SupportsLenAndGetItem[_TargetsT] -) -> tuple[list[_SourcesT], list[_TargetsT]]: ... -def newer_group( - sources: Iterable[StrOrBytesPath], target: StrOrBytesPath, missing: Literal["error", "ignore", "newer"] = "error" -) -> Literal[0, 1]: ... +from ._modified import newer as newer, newer_group as newer_group, newer_pairwise as newer_pairwise diff --git a/typings/distutils-stubs/dist.pyi b/typings/distutils-stubs/dist.pyi index 75fc7dbb38..a908efd47b 100644 --- a/typings/distutils-stubs/dist.pyi +++ b/typings/distutils-stubs/dist.pyi @@ -25,6 +25,8 @@ from re import Pattern from typing import IO, ClassVar, Literal, TypeVar, overload from typing_extensions import TypeAlias +from .cmd import Command + command_re: Pattern[str] _OptionsList: TypeAlias = list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] @@ -88,9 +90,9 @@ class Distribution: display_options: ClassVar[_OptionsList] display_option_names: ClassVar[list[str]] negative_opt: ClassVar[dict[str, str]] - verbose: Literal[0, 1] - dry_run: Literal[0, 1] - help: Literal[0, 1] + verbose: bool + dry_run: bool + help: bool command_packages: list[str] | None script_name: str | None script_args: list[str] | None @@ -109,8 +111,8 @@ class Distribution: scripts: Incomplete data_files: Incomplete password: str - command_obj: Incomplete - have_run: Incomplete + command_obj: dict[str, Command] + have_run: dict[str, bool] want_user_cfg: bool def dump_option_dicts( self, header: Incomplete | None = None, commands: Incomplete | None = None, indent: str = "" @@ -126,50 +128,50 @@ class Distribution: def get_command_packages(self): ... # NOTE: This list comes directly from the distutils/command folder. Minus bdist_msi and bdist_wininst. @overload - def get_command_obj(self, command: Literal["bdist"], create: Literal[1, True] = 1) -> bdist: ... + def get_command_obj(self, command: Literal["bdist"], create: Literal[True] = True) -> bdist: ... @overload - def get_command_obj(self, command: Literal["bdist_dumb"], create: Literal[1, True] = 1) -> bdist_dumb: ... + def get_command_obj(self, command: Literal["bdist_dumb"], create: Literal[True] = True) -> bdist_dumb: ... @overload - def get_command_obj(self, command: Literal["bdist_rpm"], create: Literal[1, True] = 1) -> bdist_rpm: ... + def get_command_obj(self, command: Literal["bdist_rpm"], create: Literal[True] = True) -> bdist_rpm: ... @overload - def get_command_obj(self, command: Literal["build"], create: Literal[1, True] = 1) -> build: ... + def get_command_obj(self, command: Literal["build"], create: Literal[True] = True) -> build: ... @overload - def get_command_obj(self, command: Literal["build_clib"], create: Literal[1, True] = 1) -> build_clib: ... + def get_command_obj(self, command: Literal["build_clib"], create: Literal[True] = True) -> build_clib: ... @overload - def get_command_obj(self, command: Literal["build_ext"], create: Literal[1, True] = 1) -> build_ext: ... + def get_command_obj(self, command: Literal["build_ext"], create: Literal[True] = True) -> build_ext: ... @overload - def get_command_obj(self, command: Literal["build_py"], create: Literal[1, True] = 1) -> build_py: ... + def get_command_obj(self, command: Literal["build_py"], create: Literal[True] = True) -> build_py: ... @overload - def get_command_obj(self, command: Literal["build_scripts"], create: Literal[1, True] = 1) -> build_scripts: ... + def get_command_obj(self, command: Literal["build_scripts"], create: Literal[True] = True) -> build_scripts: ... @overload - def get_command_obj(self, command: Literal["check"], create: Literal[1, True] = 1) -> check: ... + def get_command_obj(self, command: Literal["check"], create: Literal[True] = True) -> check: ... @overload - def get_command_obj(self, command: Literal["clean"], create: Literal[1, True] = 1) -> clean: ... + def get_command_obj(self, command: Literal["clean"], create: Literal[True] = True) -> clean: ... @overload - def get_command_obj(self, command: Literal["config"], create: Literal[1, True] = 1) -> config: ... + def get_command_obj(self, command: Literal["config"], create: Literal[True] = True) -> config: ... @overload - def get_command_obj(self, command: Literal["install"], create: Literal[1, True] = 1) -> install: ... + def get_command_obj(self, command: Literal["install"], create: Literal[True] = True) -> install: ... @overload - def get_command_obj(self, command: Literal["install_data"], create: Literal[1, True] = 1) -> install_data: ... + def get_command_obj(self, command: Literal["install_data"], create: Literal[True] = True) -> install_data: ... @overload - def get_command_obj(self, command: Literal["install_egg_info"], create: Literal[1, True] = 1) -> install_egg_info: ... + def get_command_obj(self, command: Literal["install_egg_info"], create: Literal[True] = True) -> install_egg_info: ... @overload - def get_command_obj(self, command: Literal["install_headers"], create: Literal[1, True] = 1) -> install_headers: ... + def get_command_obj(self, command: Literal["install_headers"], create: Literal[True] = True) -> install_headers: ... @overload - def get_command_obj(self, command: Literal["install_lib"], create: Literal[1, True] = 1) -> install_lib: ... + def get_command_obj(self, command: Literal["install_lib"], create: Literal[True] = True) -> install_lib: ... @overload - def get_command_obj(self, command: Literal["install_scripts"], create: Literal[1, True] = 1) -> install_scripts: ... + def get_command_obj(self, command: Literal["install_scripts"], create: Literal[True] = True) -> install_scripts: ... @overload - def get_command_obj(self, command: Literal["register"], create: Literal[1, True] = 1) -> register: ... + def get_command_obj(self, command: Literal["register"], create: Literal[True] = True) -> register: ... @overload - def get_command_obj(self, command: Literal["sdist"], create: Literal[1, True] = 1) -> sdist: ... + def get_command_obj(self, command: Literal["sdist"], create: Literal[True] = True) -> sdist: ... @overload - def get_command_obj(self, command: Literal["upload"], create: Literal[1, True] = 1) -> upload: ... + def get_command_obj(self, command: Literal["upload"], create: Literal[True] = True) -> upload: ... @overload - def get_command_obj(self, command: str, create: Literal[1, True] = 1) -> Command: ... + def get_command_obj(self, command: str, create: Literal[True] = True) -> Command: ... # Not replicating the overloads for "Command | None", user may use "isinstance" @overload - def get_command_obj(self, command: str, create: Literal[0, False]) -> Command | None: ... + def get_command_obj(self, command: str, create: Literal[False]) -> Command | None: ... @overload def get_command_class(self, command: Literal["bdist"]) -> type[bdist]: ... @overload @@ -258,7 +260,7 @@ class Distribution: def reinitialize_command(self, command: str, reinit_subcommands: bool = False) -> Command: ... @overload def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool = False) -> _CommandT: ... - def announce(self, msg, level: int = 2) -> None: ... + def announce(self, msg, level: int = 20) -> None: ... def run_commands(self) -> None: ... def run_command(self, command: str) -> None: ... def has_pure_modules(self) -> bool: ... @@ -294,24 +296,24 @@ class Distribution: def get_obsoletes(self) -> list[str]: ... # Default attributes generated in __init__ from self.display_option_names - help_commands: bool | Literal[0] - name: str | Literal[0] - version: str | Literal[0] - fullname: str | Literal[0] - author: str | Literal[0] - author_email: str | Literal[0] - maintainer: str | Literal[0] - maintainer_email: str | Literal[0] - contact: str | Literal[0] - contact_email: str | Literal[0] - url: str | Literal[0] - license: str | Literal[0] - licence: str | Literal[0] - description: str | Literal[0] - long_description: str | Literal[0] - platforms: str | list[str] | Literal[0] - classifiers: str | list[str] | Literal[0] - keywords: str | list[str] | Literal[0] - provides: list[str] | Literal[0] - requires: list[str] | Literal[0] - obsoletes: list[str] | Literal[0] + help_commands: bool + name: str | Literal[False] + version: str | Literal[False] + fullname: str | Literal[False] + author: str | Literal[False] + author_email: str | Literal[False] + maintainer: str | Literal[False] + maintainer_email: str | Literal[False] + contact: str | Literal[False] + contact_email: str | Literal[False] + url: str | Literal[False] + license: str | Literal[False] + licence: str | Literal[False] + description: str | Literal[False] + long_description: str | Literal[False] + platforms: str | list[str] | Literal[False] + classifiers: str | list[str] | Literal[False] + keywords: str | list[str] | Literal[False] + provides: list[str] | Literal[False] + requires: list[str] | Literal[False] + obsoletes: list[str] | Literal[False] diff --git a/typings/distutils-stubs/filelist.pyi b/typings/distutils-stubs/filelist.pyi index 607a78a1fb..4f3a83c97d 100644 --- a/typings/distutils-stubs/filelist.pyi +++ b/typings/distutils-stubs/filelist.pyi @@ -1,3 +1,4 @@ +import os from collections.abc import Iterable from re import Pattern from typing import Literal, overload @@ -8,7 +9,7 @@ class FileList: files: list[str] def __init__(self, warn: None = None, debug_print: None = None) -> None: ... def set_allfiles(self, allfiles: Iterable[str]) -> None: ... - def findall(self, dir: str = ".") -> None: ... + def findall(self, dir: str = os.curdir) -> None: ... def debug_print(self, msg: str) -> None: ... def append(self, item: str) -> None: ... def extend(self, items: Iterable[str]) -> None: ... @@ -17,42 +18,21 @@ class FileList: def process_template_line(self, line: str) -> None: ... @overload def include_pattern( - self, pattern: str, anchor: bool | Literal[0, 1] = 1, prefix: str | None = None, is_regex: Literal[0, False] = 0 + self, pattern: str, anchor: bool = True, prefix: str | None = None, is_regex: Literal[0, False] = 0 ) -> bool: ... @overload def include_pattern(self, pattern: str | Pattern[str], *, is_regex: Literal[True, 1]) -> bool: ... @overload def include_pattern( - self, - pattern: str | Pattern[str], - anchor: bool | Literal[0, 1] = 1, - prefix: str | None = None, - is_regex: bool | Literal[0, 1] = 0, + self, pattern: str | Pattern[str], anchor: bool = True, prefix: str | None = None, is_regex: bool = False ) -> bool: ... @overload def exclude_pattern( - self, pattern: str, anchor: bool | Literal[0, 1] = 1, prefix: str | None = None, is_regex: Literal[0, False] = 0 + self, pattern: str, anchor: bool = True, prefix: str | None = None, is_regex: Literal[0, False] = 0 ) -> bool: ... @overload def exclude_pattern(self, pattern: str | Pattern[str], *, is_regex: Literal[True, 1]) -> bool: ... @overload def exclude_pattern( - self, - pattern: str | Pattern[str], - anchor: bool | Literal[0, 1] = 1, - prefix: str | None = None, - is_regex: bool | Literal[0, 1] = 0, + self, pattern: str | Pattern[str], anchor: bool = True, prefix: str | None = None, is_regex: bool = False ) -> bool: ... - -def findall(dir: str = ".") -> list[str]: ... -def glob_to_re(pattern: str) -> str: ... -@overload -def translate_pattern( - pattern: str, anchor: bool | Literal[0, 1] = 1, prefix: str | None = None, is_regex: Literal[False, 0] = 0 -) -> Pattern[str]: ... -@overload -def translate_pattern(pattern: str | Pattern[str], *, is_regex: Literal[True, 1]) -> Pattern[str]: ... -@overload -def translate_pattern( - pattern: str | Pattern[str], anchor: bool | Literal[0, 1] = 1, prefix: str | None = None, is_regex: bool | Literal[0, 1] = 0 -) -> Pattern[str]: ... diff --git a/typings/distutils-stubs/sysconfig.pyi b/typings/distutils-stubs/sysconfig.pyi index 4a9c45eb56..b75ae74fca 100644 --- a/typings/distutils-stubs/sysconfig.pyi +++ b/typings/distutils-stubs/sysconfig.pyi @@ -1,19 +1,13 @@ -import sys -from collections.abc import Mapping -from distutils.ccompiler import CCompiler from typing import Final, Literal, overload from typing_extensions import deprecated +from setuptools._distutils.ccompiler import CCompiler + PREFIX: Final[str] EXEC_PREFIX: Final[str] -BASE_PREFIX: Final[str] -BASE_EXEC_PREFIX: Final[str] -project_base: Final[str] -python_build: Final[bool] -def expand_makefile_vars(s: str, vars: Mapping[str, str]) -> str: ... @overload -@deprecated("SO is deprecated, use EXT_SUFFIX. Support is removed in Python 3.11") +@deprecated("SO is deprecated, use EXT_SUFFIX. Support will be removed when this module is synchronized with stdlib Python 3.11") def get_config_var(name: Literal["SO"]) -> int | str | None: ... @overload def get_config_var(name: str) -> int | str | None: ... @@ -23,11 +17,6 @@ def get_config_vars() -> dict[str, str | int]: ... def get_config_vars(arg: str, /, *args: str) -> list[str | int]: ... def get_config_h_filename() -> str: ... def get_makefile_filename() -> str: ... -def get_python_inc(plat_specific: bool | Literal[0, 1] = 0, prefix: str | None = None) -> str: ... -def get_python_lib( - plat_specific: bool | Literal[0, 1] = 0, standard_lib: bool | Literal[0, 1] = 0, prefix: str | None = None -) -> str: ... +def get_python_inc(plat_specific: bool = False, prefix: str | None = None) -> str: ... +def get_python_lib(plat_specific: bool = False, standard_lib: bool = False, prefix: str | None = None) -> str: ... def customize_compiler(compiler: CCompiler) -> None: ... - -if sys.version_info < (3, 10): - def get_python_version() -> str: ... diff --git a/typings/distutils-stubs/util.pyi b/typings/distutils-stubs/util.pyi index 0e1bb4165d..7a01252ea5 100644 --- a/typings/distutils-stubs/util.pyi +++ b/typings/distutils-stubs/util.pyi @@ -1,53 +1,38 @@ -from _typeshed import StrPath, Unused -from collections.abc import Callable, Container, Iterable, Mapping -from typing import Any, Literal +from _typeshed import Unused +from collections.abc import Callable, Mapping +from typing import Literal from typing_extensions import TypeVarTuple, Unpack _Ts = TypeVarTuple("_Ts") def get_host_platform() -> str: ... def get_platform() -> str: ... +def get_macosx_target_ver_from_syscfg(): ... +def get_macosx_target_ver(): ... +def split_version(s: str) -> list[int]: ... def convert_path(pathname: str) -> str: ... -def change_root(new_root: StrPath, pathname: StrPath) -> str: ... +def change_root(new_root: str, pathname: str) -> str: ... def check_environ() -> None: ... def subst_vars(s: str, local_vars: Mapping[str, str]) -> None: ... +def grok_environment_error(exc: object, prefix: str = "error: ") -> str: ... def split_quoted(s: str) -> list[str]: ... def execute( func: Callable[[Unpack[_Ts]], Unused], args: tuple[Unpack[_Ts]], msg: str | None = None, - verbose: bool | Literal[0, 1] = 0, - dry_run: bool | Literal[0, 1] = 0, + verbose: bool = False, + dry_run: bool = False, ) -> None: ... def strtobool(val: str) -> Literal[0, 1]: ... def byte_compile( py_files: list[str], optimize: int = 0, - force: bool | Literal[0, 1] = 0, + force: bool = False, prefix: str | None = None, base_dir: str | None = None, - verbose: bool | Literal[0, 1] = 1, - dry_run: bool | Literal[0, 1] = 0, + verbose: bool = True, + dry_run: bool = False, direct: bool | None = None, ) -> None: ... def rfc822_escape(header: str) -> str: ... -def run_2to3( - files: Iterable[str], - fixer_names: Iterable[str] | None = None, - options: Mapping[str, Any] | None = None, - explicit: Unused = None, -) -> None: ... -def copydir_run_2to3( - src: StrPath, - dest: StrPath, - template: str | None = None, - fixer_names: Iterable[str] | None = None, - options: Mapping[str, Any] | None = None, - explicit: Container[str] | None = None, -) -> list[str]: ... - -class Mixin2to3: - fixer_names: Iterable[str] | None - options: Mapping[str, Any] | None - explicit: Container[str] | None - def run_2to3(self, files: Iterable[str]) -> None: ... +def is_mingw() -> bool: ... From bdb75303d4ccc031798ea92eccc5a1a4396da6e9 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 17 Oct 2024 17:39:45 -0400 Subject: [PATCH 4/6] Fixups and use Incomplete instead of Any --- typings/distutils-stubs/__init__.pyi | 5 -- typings/distutils-stubs/ccompiler.pyi | 63 ++++++++++++++----- typings/distutils-stubs/cmd.pyi | 1 - .../distutils-stubs/command/bdist_dumb.pyi | 17 ++--- typings/distutils-stubs/command/build_py.pyi | 2 +- .../distutils-stubs/command/build_scripts.pyi | 19 +++--- typings/distutils-stubs/command/check.pyi | 19 +++--- typings/distutils-stubs/command/clean.pyi | 15 ++--- typings/distutils-stubs/command/config.pyi | 23 ++++--- .../distutils-stubs/command/install_data.pyi | 11 ++-- .../command/install_egg_info.pyi | 9 +-- .../command/install_headers.pyi | 7 ++- typings/distutils-stubs/command/register.pyi | 5 +- typings/distutils-stubs/command/upload.pyi | 9 +-- typings/distutils-stubs/core.pyi | 19 +++--- typings/distutils-stubs/dir_util.pyi | 31 +++++---- typings/distutils-stubs/fancy_getopt.pyi | 6 +- typings/distutils-stubs/file_util.pyi | 35 ++++++----- typings/distutils-stubs/filelist.pyi | 35 ++++++++--- typings/distutils-stubs/log.pyi | 26 ++++---- typings/distutils-stubs/spawn.pyi | 7 ++- typings/distutils-stubs/text_file.pyi | 18 +++--- typings/distutils-stubs/util.pyi | 6 +- typings/distutils-stubs/version.pyi | 4 +- 24 files changed, 239 insertions(+), 153 deletions(-) diff --git a/typings/distutils-stubs/__init__.pyi b/typings/distutils-stubs/__init__.pyi index 328a5b7834..e69de29bb2 100644 --- a/typings/distutils-stubs/__init__.pyi +++ b/typings/distutils-stubs/__init__.pyi @@ -1,5 +0,0 @@ -# Attempts to improve these stubs are probably not the best use of time: -# - distutils is deleted in Python 3.12 and newer -# - Most users already do not use stdlib distutils, due to setuptools monkeypatching -# - We have very little quality assurance on these stubs, since due to the two above issues -# we allowlist all distutils errors in stubtest. diff --git a/typings/distutils-stubs/ccompiler.pyi b/typings/distutils-stubs/ccompiler.pyi index 465b9c977e..bd5a79bc68 100644 --- a/typings/distutils-stubs/ccompiler.pyi +++ b/typings/distutils-stubs/ccompiler.pyi @@ -1,6 +1,7 @@ -from _typeshed import BytesPath, StrPath, Unused from collections.abc import Callable, Iterable from typing import ClassVar, Literal, TypeVar, overload + +from _typeshed import BytesPath, StrPath, Unused from typing_extensions import TypeAlias, TypeVarTuple, Unpack _Macro: TypeAlias = tuple[str] | tuple[str, str | None] @@ -9,12 +10,23 @@ _BytesPathT = TypeVar("_BytesPathT", bound=BytesPath) _Ts = TypeVarTuple("_Ts") def gen_lib_options( - compiler: CCompiler, library_dirs: list[str], runtime_library_dirs: list[str], libraries: list[str] + compiler: CCompiler, + library_dirs: list[str], + runtime_library_dirs: list[str], + libraries: list[str], ) -> list[str]: ... -def gen_preprocess_options(macros: list[_Macro], include_dirs: list[str]) -> list[str]: ... -def get_default_compiler(osname: str | None = None, platform: str | None = None) -> str: ... +def gen_preprocess_options( + macros: list[_Macro], include_dirs: list[str] +) -> list[str]: ... +def get_default_compiler( + osname: str | None = None, platform: str | None = None +) -> str: ... def new_compiler( - plat: str | None = None, compiler: str | None = None, verbose: bool = False, dry_run: bool = False, force: bool = False + plat: str | None = None, + compiler: str | None = None, + verbose: bool = False, + dry_run: bool = False, + force: bool = False, ) -> CCompiler: ... def show_compilers() -> None: ... @@ -38,7 +50,9 @@ class CCompiler: library_dirs: list[str] runtime_library_dirs: list[str] objects: list[str] - def __init__(self, verbose: bool = False, dry_run: bool = False, force: bool = False) -> None: ... + def __init__( + self, verbose: bool = False, dry_run: bool = False, force: bool = False + ) -> None: ... def add_include_dir(self, dir: str) -> None: ... def set_include_dirs(self, dirs: list[str]) -> None: ... def add_library(self, libname: str) -> None: ... @@ -52,7 +66,9 @@ class CCompiler: def add_link_object(self, object: str) -> None: ... def set_link_objects(self, objects: list[str]) -> None: ... def detect_language(self, sources: str | list[str]) -> str | None: ... - def find_library_file(self, dirs: list[str], lib: str, debug: bool = False) -> str | None: ... + def find_library_file( + self, dirs: list[str], lib: str, debug: bool = False + ) -> str | None: ... def has_function( self, funcname: str, @@ -153,21 +169,40 @@ class CCompiler: extra_postargs: list[str] | None = None, ) -> None: ... @overload - def executable_filename(self, basename: str, strip_dir: Literal[0, False] = 0, output_dir: StrPath = "") -> str: ... + def executable_filename( + self, basename: str, strip_dir: Literal[False] = False, output_dir: StrPath = "" + ) -> str: ... @overload - def executable_filename(self, basename: StrPath, strip_dir: Literal[1, True], output_dir: StrPath = "") -> str: ... + def executable_filename( + self, basename: StrPath, strip_dir: Literal[True], output_dir: StrPath = "" + ) -> str: ... def library_filename( - self, libname: str, lib_type: str = "static", strip_dir: bool = False, output_dir: StrPath = "" + self, + libname: str, + lib_type: str = "static", + strip_dir: bool = False, + output_dir: StrPath = "", ) -> str: ... def object_filenames( - self, source_filenames: Iterable[StrPath], strip_dir: bool = False, output_dir: StrPath | None = None + self, + source_filenames: Iterable[StrPath], + strip_dir: bool = False, + output_dir: StrPath | None = '', ) -> list[str]: ... @overload - def shared_object_filename(self, basename: str, strip_dir: Literal[0, False] = 0, output_dir: StrPath = "") -> str: ... + def shared_object_filename( + self, basename: str, strip_dir: Literal[False] = False, output_dir: StrPath = "" + ) -> str: ... @overload - def shared_object_filename(self, basename: StrPath, strip_dir: Literal[1, True], output_dir: StrPath = "") -> str: ... + def shared_object_filename( + self, basename: StrPath, strip_dir: Literal[True], output_dir: StrPath = "" + ) -> str: ... def execute( - self, func: Callable[[Unpack[_Ts]], Unused], args: tuple[Unpack[_Ts]], msg: str | None = None, level: int = 1 + self, + func: Callable[[Unpack[_Ts]], Unused], + args: tuple[Unpack[_Ts]], + msg: str | None = None, + level: int = 1, ) -> None: ... def spawn(self, cmd: list[str]) -> None: ... def mkpath(self, name: str, mode: int = 0o777) -> None: ... diff --git a/typings/distutils-stubs/cmd.pyi b/typings/distutils-stubs/cmd.pyi index fb9cc06b03..a483ba60f3 100644 --- a/typings/distutils-stubs/cmd.pyi +++ b/typings/distutils-stubs/cmd.pyi @@ -23,7 +23,6 @@ from distutils.command.register import register from distutils.command.sdist import sdist from distutils.command.upload import upload from distutils.dist import Distribution -from distutils.file_util import _BytesPathT, _StrPathT from typing import Any, ClassVar, Literal, TypeVar, overload from typing_extensions import TypeVarTuple, Unpack diff --git a/typings/distutils-stubs/command/bdist_dumb.pyi b/typings/distutils-stubs/command/bdist_dumb.pyi index 19997882dd..297a0c39ed 100644 --- a/typings/distutils-stubs/command/bdist_dumb.pyi +++ b/typings/distutils-stubs/command/bdist_dumb.pyi @@ -1,4 +1,5 @@ -from typing import Any, ClassVar +from _typeshed import Incomplete +from typing import ClassVar from ..cmd import Command @@ -7,15 +8,15 @@ class bdist_dumb(Command): user_options: ClassVar[list[tuple[str, str | None, str]]] boolean_options: ClassVar[list[str]] default_format: ClassVar[dict[str, str]] - bdist_dir: Any - plat_name: Any - format: Any + bdist_dir: Incomplete + plat_name: Incomplete + format: Incomplete keep_temp: int - dist_dir: Any - skip_build: Any + dist_dir: Incomplete + skip_build: Incomplete relative: int - owner: Any - group: Any + owner: Incomplete + group: Incomplete def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... def run(self) -> None: ... diff --git a/typings/distutils-stubs/command/build_py.pyi b/typings/distutils-stubs/command/build_py.pyi index 67515b9bf0..6ad82d005e 100644 --- a/typings/distutils-stubs/command/build_py.pyi +++ b/typings/distutils-stubs/command/build_py.pyi @@ -32,7 +32,7 @@ class build_py(Command): def find_all_modules(self): ... def get_source_files(self): ... def get_module_outfile(self, build_dir, package, module): ... - def get_outputs(self, include_bytecode: bool = True): ... + def get_outputs(self, include_bytecode: bool = True) -> list[str]: ... def build_module(self, module, module_file, package): ... def build_modules(self) -> None: ... def build_packages(self) -> None: ... diff --git a/typings/distutils-stubs/command/build_scripts.pyi b/typings/distutils-stubs/command/build_scripts.pyi index 7871bb8a57..74ca2cacd9 100644 --- a/typings/distutils-stubs/command/build_scripts.pyi +++ b/typings/distutils-stubs/command/build_scripts.pyi @@ -1,24 +1,21 @@ -from typing import Any, ClassVar +from _typeshed import Incomplete +from typing import ClassVar from ..cmd import Command -from ..util import Mixin2to3 as Mixin2to3 -first_line_re: Any +first_line_re: Incomplete class build_scripts(Command): description: str user_options: ClassVar[list[tuple[str, str, str]]] boolean_options: ClassVar[list[str]] - build_dir: Any - scripts: Any - force: Any - executable: Any - outfiles: Any + build_dir: Incomplete + scripts: Incomplete + force: Incomplete + executable: Incomplete + outfiles: Incomplete def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... def get_source_files(self): ... def run(self) -> None: ... def copy_scripts(self): ... - -class build_scripts_2to3(build_scripts, Mixin2to3): - def copy_scripts(self): ... diff --git a/typings/distutils-stubs/command/check.pyi b/typings/distutils-stubs/command/check.pyi index e69627d20c..55b4da71b7 100644 --- a/typings/distutils-stubs/command/check.pyi +++ b/typings/distutils-stubs/command/check.pyi @@ -1,22 +1,19 @@ -from typing import Any, ClassVar, Final, Literal -from typing_extensions import TypeAlias +from typing import ClassVar, Final -from ..cmd import Command +from _typeshed import Incomplete +from docutils.utils import Reporter -_Reporter: TypeAlias = Any # really docutils.utils.Reporter +from ..cmd import Command -# Only defined if docutils is installed. -# Depends on a third-party stub. Since distutils is deprecated anyway, -# it's easier to just suppress the "any subclassing" error. -class SilentReporter(_Reporter): - messages: Any +class SilentReporter(Reporter): + messages: Incomplete def __init__( self, source, report_level, halt_level, - stream: Any | None = ..., - debug: bool | Literal[0, 1] = 0, + stream: Incomplete | None = ..., + debug: bool = False, encoding: str = ..., error_handler: str = ..., ) -> None: ... diff --git a/typings/distutils-stubs/command/clean.pyi b/typings/distutils-stubs/command/clean.pyi index 55f0a0eeaf..0f3768d6dc 100644 --- a/typings/distutils-stubs/command/clean.pyi +++ b/typings/distutils-stubs/command/clean.pyi @@ -1,4 +1,5 @@ -from typing import Any, ClassVar +from _typeshed import Incomplete +from typing import ClassVar from ..cmd import Command @@ -6,12 +7,12 @@ class clean(Command): description: str user_options: ClassVar[list[tuple[str, str | None, str]]] boolean_options: ClassVar[list[str]] - build_base: Any - build_lib: Any - build_temp: Any - build_scripts: Any - bdist_base: Any - all: Any + build_base: Incomplete + build_lib: Incomplete + build_temp: Incomplete + build_scripts: Incomplete + bdist_base: Incomplete + all: Incomplete def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... def run(self) -> None: ... diff --git a/typings/distutils-stubs/command/config.pyi b/typings/distutils-stubs/command/config.pyi index b0910091d5..3145141849 100644 --- a/typings/distutils-stubs/command/config.pyi +++ b/typings/distutils-stubs/command/config.pyi @@ -1,7 +1,8 @@ -from _typeshed import StrOrBytesPath from collections.abc import Sequence from re import Pattern -from typing import Any, ClassVar, Final, Literal +from typing import ClassVar, Final + +from _typeshed import Incomplete, StrOrBytesPath from ..ccompiler import CCompiler from ..cmd import Command @@ -39,7 +40,11 @@ class config(Command): lang: str = "c", ) -> bool: ... def try_compile( - self, body: str, headers: Sequence[str] | None = None, include_dirs: Sequence[str] | None = None, lang: str = "c" + self, + body: str, + headers: Sequence[str] | None = None, + include_dirs: Sequence[str] | None = None, + lang: str = "c", ) -> bool: ... def try_link( self, @@ -66,8 +71,8 @@ class config(Command): include_dirs: Sequence[str] | None = None, libraries: Sequence[str] | None = None, library_dirs: Sequence[str] | None = None, - decl: bool | Literal[0, 1] = 0, - call: bool | Literal[0, 1] = 0, + decl: bool = False, + call: bool = False, ) -> bool: ... def check_lib( self, @@ -78,7 +83,11 @@ class config(Command): other_libraries: list[str] = [], ) -> bool: ... def check_header( - self, header: str, include_dirs: Sequence[str] | None = None, library_dirs: Sequence[str] | None = None, lang: str = "c" + self, + header: str, + include_dirs: Sequence[str] | None = None, + library_dirs: Sequence[str] | None = None, + lang: str = "c", ) -> bool: ... -def dump_file(filename: StrOrBytesPath, head: Any | None = None) -> None: ... +def dump_file(filename: StrOrBytesPath, head: Incomplete | None = None) -> None: ... diff --git a/typings/distutils-stubs/command/install_data.pyi b/typings/distutils-stubs/command/install_data.pyi index 342c7a7ccc..609de62b04 100644 --- a/typings/distutils-stubs/command/install_data.pyi +++ b/typings/distutils-stubs/command/install_data.pyi @@ -1,4 +1,5 @@ -from typing import Any, ClassVar +from _typeshed import Incomplete +from typing import ClassVar from ..cmd import Command @@ -6,11 +7,11 @@ class install_data(Command): description: str user_options: ClassVar[list[tuple[str, str | None, str]]] boolean_options: ClassVar[list[str]] - install_dir: Any - outfiles: Any - root: Any + install_dir: Incomplete + outfiles: Incomplete + root: Incomplete force: int - data_files: Any + data_files: Incomplete warn_dir: int def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... diff --git a/typings/distutils-stubs/command/install_egg_info.pyi b/typings/distutils-stubs/command/install_egg_info.pyi index 3fd54989d1..75bb906ce5 100644 --- a/typings/distutils-stubs/command/install_egg_info.pyi +++ b/typings/distutils-stubs/command/install_egg_info.pyi @@ -1,14 +1,15 @@ -from typing import Any, ClassVar +from _typeshed import Incomplete +from typing import ClassVar from ..cmd import Command class install_egg_info(Command): description: ClassVar[str] user_options: ClassVar[list[tuple[str, str, str]]] - install_dir: Any + install_dir: Incomplete def initialize_options(self) -> None: ... - target: Any - outputs: Any + target: Incomplete + outputs: Incomplete def finalize_options(self) -> None: ... def run(self) -> None: ... def get_outputs(self) -> list[str]: ... diff --git a/typings/distutils-stubs/command/install_headers.pyi b/typings/distutils-stubs/command/install_headers.pyi index 7854d2393a..3caad8a07d 100644 --- a/typings/distutils-stubs/command/install_headers.pyi +++ b/typings/distutils-stubs/command/install_headers.pyi @@ -1,4 +1,5 @@ -from typing import Any, ClassVar +from _typeshed import Incomplete +from typing import ClassVar from ..cmd import Command @@ -6,9 +7,9 @@ class install_headers(Command): description: str user_options: ClassVar[list[tuple[str, str, str]]] boolean_options: ClassVar[list[str]] - install_dir: Any + install_dir: Incomplete force: int - outfiles: Any + outfiles: Incomplete def initialize_options(self) -> None: ... def finalize_options(self) -> None: ... def run(self) -> None: ... diff --git a/typings/distutils-stubs/command/register.pyi b/typings/distutils-stubs/command/register.pyi index a5e251d2d0..6f5901ffbc 100644 --- a/typings/distutils-stubs/command/register.pyi +++ b/typings/distutils-stubs/command/register.pyi @@ -1,3 +1,4 @@ +from _typeshed import Incomplete from collections.abc import Callable from typing import Any, ClassVar @@ -17,4 +18,6 @@ class register(PyPIRCCommand): def verify_metadata(self) -> None: ... def send_metadata(self) -> None: ... def build_post_data(self, action): ... - def post_to_server(self, data, auth: Any | None = None): ... + def post_to_server( + self, data, auth: Incomplete | None = None + ) -> tuple[int, str]: ... diff --git a/typings/distutils-stubs/command/upload.pyi b/typings/distutils-stubs/command/upload.pyi index e6b77825c5..afcfbaf486 100644 --- a/typings/distutils-stubs/command/upload.pyi +++ b/typings/distutils-stubs/command/upload.pyi @@ -1,4 +1,5 @@ -from typing import Any, ClassVar +from _typeshed import Incomplete +from typing import ClassVar from ..config import PyPIRCCommand @@ -8,10 +9,10 @@ class upload(PyPIRCCommand): password: str show_response: int sign: bool - identity: Any + identity: Incomplete def initialize_options(self) -> None: ... - repository: Any - realm: Any + repository: Incomplete + realm: Incomplete def finalize_options(self) -> None: ... def run(self) -> None: ... def upload_file(self, command: str, pyversion: str, filename: str) -> None: ... diff --git a/typings/distutils-stubs/core.pyi b/typings/distutils-stubs/core.pyi index a4d21f8ddd..32695ec2d9 100644 --- a/typings/distutils-stubs/core.pyi +++ b/typings/distutils-stubs/core.pyi @@ -1,9 +1,11 @@ -from _typeshed import StrOrBytesPath from collections.abc import Mapping +from typing import Final + +from _typeshed import Incomplete, StrOrBytesPath + from distutils.cmd import Command as Command from distutils.dist import Distribution as Distribution from distutils.extension import Extension as Extension -from typing import Any, Final, Literal USAGE: Final[str] @@ -32,7 +34,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 = ..., @@ -43,15 +45,18 @@ 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 | Literal[0, 1] = ..., + include_package_data: bool = ..., libraries: list[str] = ..., headers: list[str] = ..., ext_package: str = ..., include_dirs: list[str] = ..., password: str = ..., fullname: str = ..., - **attrs: Any, + # Custom Distributions could accept more params + **attrs: object, +) -> Distribution: ... +def run_setup( + script_name: str, script_args: list[str] | None = None, stop_after: str = "run" ) -> Distribution: ... -def run_setup(script_name: str, script_args: list[str] | None = None, stop_after: str = "run") -> Distribution: ... diff --git a/typings/distutils-stubs/dir_util.pyi b/typings/distutils-stubs/dir_util.pyi index 23e2c3bc28..b77b7ef632 100644 --- a/typings/distutils-stubs/dir_util.pyi +++ b/typings/distutils-stubs/dir_util.pyi @@ -1,23 +1,30 @@ -from _typeshed import StrOrBytesPath, StrPath from collections.abc import Iterable -from typing import Literal -def mkpath(name: str, mode: int = 0o777, verbose: bool | Literal[0, 1] = 1, dry_run: bool | Literal[0, 1] = 0) -> list[str]: ... +from _typeshed import StrOrBytesPath, StrPath + +def mkpath( + name: str, + mode: int = 0o777, + verbose: bool = True, + dry_run: bool = False, +) -> list[str]: ... def create_tree( base_dir: StrPath, files: Iterable[StrPath], mode: int = 0o777, - verbose: bool | Literal[0, 1] = 1, - dry_run: bool | Literal[0, 1] = 0, + verbose: bool = True, + dry_run: bool = False, ) -> None: ... def copy_tree( src: StrPath, dst: str, - preserve_mode: bool | Literal[0, 1] = 1, - preserve_times: bool | Literal[0, 1] = 1, - preserve_symlinks: bool | Literal[0, 1] = 0, - update: bool | Literal[0, 1] = 0, - verbose: bool | Literal[0, 1] = 1, - dry_run: bool | Literal[0, 1] = 0, + preserve_mode: bool = True, + preserve_times: bool = True, + preserve_symlinks: bool = False, + update: bool = False, + verbose: bool = True, + dry_run: bool = False, ) -> list[str]: ... -def remove_tree(directory: StrOrBytesPath, verbose: bool | Literal[0, 1] = 1, dry_run: bool | Literal[0, 1] = 0) -> None: ... +def remove_tree( + directory: StrOrBytesPath, verbose: bool = True, dry_run: bool = False +) -> None: ... diff --git a/typings/distutils-stubs/fancy_getopt.pyi b/typings/distutils-stubs/fancy_getopt.pyi index c4d37419ed..f51921b607 100644 --- a/typings/distutils-stubs/fancy_getopt.pyi +++ b/typings/distutils-stubs/fancy_getopt.pyi @@ -1,6 +1,7 @@ from collections.abc import Iterable, Mapping from re import Pattern from typing import Any, Final, overload + from typing_extensions import TypeAlias _Option: TypeAlias = tuple[str, str | None, str] @@ -22,7 +23,10 @@ class FancyGetopt: def generate_help(self, header: str | None = None) -> list[str]: ... def fancy_getopt( - options: list[_Option], negative_opt: Mapping[_Option, _Option], object: Any, args: list[str] | None + options: list[_Option], + negative_opt: Mapping[_Option, _Option], + object: Any, + args: list[str] | None, ) -> list[str] | _GR: ... WS_TRANS: Final[dict[int, str]] diff --git a/typings/distutils-stubs/file_util.pyi b/typings/distutils-stubs/file_util.pyi index 873d23ea7e..5720ff28af 100644 --- a/typings/distutils-stubs/file_util.pyi +++ b/typings/distutils-stubs/file_util.pyi @@ -1,6 +1,7 @@ -from _typeshed import BytesPath, StrOrBytesPath, StrPath from collections.abc import Iterable -from typing import Literal, TypeVar, overload +from typing import TypeVar, overload + +from _typeshed import BytesPath, StrOrBytesPath, StrPath _StrPathT = TypeVar("_StrPathT", bound=StrPath) _BytesPathT = TypeVar("_BytesPathT", bound=BytesPath) @@ -9,30 +10,36 @@ _BytesPathT = TypeVar("_BytesPathT", bound=BytesPath) def copy_file( src: StrPath, dst: _StrPathT, - preserve_mode: bool | Literal[0, 1] = 1, - preserve_times: bool | Literal[0, 1] = 1, - update: bool | Literal[0, 1] = 0, + preserve_mode: bool = True, + preserve_times: bool = True, + update: bool = False, link: str | None = None, - verbose: bool | Literal[0, 1] = 1, - dry_run: bool | Literal[0, 1] = 0, + verbose: bool = True, + dry_run: bool = False, ) -> tuple[_StrPathT | str, bool]: ... @overload def copy_file( src: BytesPath, dst: _BytesPathT, - preserve_mode: bool | Literal[0, 1] = 1, - preserve_times: bool | Literal[0, 1] = 1, - update: bool | Literal[0, 1] = 0, + preserve_mode: bool = True, + preserve_times: bool = True, + update: bool = False, link: str | None = None, - verbose: bool | Literal[0, 1] = 1, - dry_run: bool | Literal[0, 1] = 0, + verbose: bool = True, + dry_run: bool = False, ) -> tuple[_BytesPathT | bytes, bool]: ... @overload def move_file( - src: StrPath, dst: _StrPathT, verbose: bool | Literal[0, 1] = 0, dry_run: bool | Literal[0, 1] = 0 + src: StrPath, + dst: _StrPathT, + verbose: bool = False, + dry_run: bool = False, ) -> _StrPathT | str: ... @overload def move_file( - src: BytesPath, dst: _BytesPathT, verbose: bool | Literal[0, 1] = 0, dry_run: bool | Literal[0, 1] = 0 + src: BytesPath, + dst: _BytesPathT, + verbose: bool = False, + dry_run: bool = False, ) -> _BytesPathT | bytes: ... def write_file(filename: StrOrBytesPath, contents: Iterable[str]) -> None: ... diff --git a/typings/distutils-stubs/filelist.pyi b/typings/distutils-stubs/filelist.pyi index 4f3a83c97d..0ca877eb17 100644 --- a/typings/distutils-stubs/filelist.pyi +++ b/typings/distutils-stubs/filelist.pyi @@ -1,4 +1,3 @@ -import os from collections.abc import Iterable from re import Pattern from typing import Literal, overload @@ -9,7 +8,7 @@ class FileList: files: list[str] def __init__(self, warn: None = None, debug_print: None = None) -> None: ... def set_allfiles(self, allfiles: Iterable[str]) -> None: ... - def findall(self, dir: str = os.curdir) -> None: ... + def findall(self, dir: str = ...) -> None: ... def debug_print(self, msg: str) -> None: ... def append(self, item: str) -> None: ... def extend(self, items: Iterable[str]) -> None: ... @@ -18,21 +17,41 @@ class FileList: def process_template_line(self, line: str) -> None: ... @overload def include_pattern( - self, pattern: str, anchor: bool = True, prefix: str | None = None, is_regex: Literal[0, False] = 0 + self, + pattern: str, + anchor: bool = True, + prefix: str | None = None, + is_regex: Literal[False] = False, ) -> bool: ... @overload - def include_pattern(self, pattern: str | Pattern[str], *, is_regex: Literal[True, 1]) -> bool: ... + def include_pattern( + self, pattern: str | Pattern[str], *, is_regex: Literal[True, 1] + ) -> bool: ... @overload def include_pattern( - self, pattern: str | Pattern[str], anchor: bool = True, prefix: str | None = None, is_regex: bool = False + self, + pattern: str | Pattern[str], + anchor: bool = True, + prefix: str | None = None, + is_regex: bool = False, ) -> bool: ... @overload def exclude_pattern( - self, pattern: str, anchor: bool = True, prefix: str | None = None, is_regex: Literal[0, False] = 0 + self, + pattern: str, + anchor: bool = True, + prefix: str | None = None, + is_regex: Literal[False] = False, ) -> bool: ... @overload - def exclude_pattern(self, pattern: str | Pattern[str], *, is_regex: Literal[True, 1]) -> bool: ... + def exclude_pattern( + self, pattern: str | Pattern[str], *, is_regex: Literal[True, 1] + ) -> bool: ... @overload def exclude_pattern( - self, pattern: str | Pattern[str], anchor: bool = True, prefix: str | None = None, is_regex: bool = False + self, + pattern: str | Pattern[str], + anchor: bool = True, + prefix: str | None = None, + is_regex: bool = False, ) -> bool: ... diff --git a/typings/distutils-stubs/log.pyi b/typings/distutils-stubs/log.pyi index 0ea135c283..5d113cb11c 100644 --- a/typings/distutils-stubs/log.pyi +++ b/typings/distutils-stubs/log.pyi @@ -1,4 +1,4 @@ -from typing import Any, Final +from typing import Final DEBUG: Final = 1 INFO: Final = 2 @@ -8,18 +8,18 @@ FATAL: Final = 5 class Log: def __init__(self, threshold: int = 3) -> None: ... - def log(self, level: int, msg: str, *args: Any) -> None: ... - def debug(self, msg: str, *args: Any) -> None: ... - def info(self, msg: str, *args: Any) -> None: ... - def warn(self, msg: str, *args: Any) -> None: ... - def error(self, msg: str, *args: Any) -> None: ... - def fatal(self, msg: str, *args: Any) -> None: ... + def log(self, level: int, msg: str, *args: object) -> None: ... + def debug(self, msg: str, *args: object) -> None: ... + def info(self, msg: str, *args: object) -> None: ... + def warn(self, msg: str, *args: object) -> None: ... + def error(self, msg: str, *args: object) -> None: ... + def fatal(self, msg: str, *args: object) -> None: ... -def log(level: int, msg: str, *args: Any) -> None: ... -def debug(msg: str, *args: Any) -> None: ... -def info(msg: str, *args: Any) -> None: ... -def warn(msg: str, *args: Any) -> None: ... -def error(msg: str, *args: Any) -> None: ... -def fatal(msg: str, *args: Any) -> None: ... +def log(level: int, msg: str, *args: object) -> None: ... +def debug(msg: str, *args: object) -> None: ... +def info(msg: str, *args: object) -> None: ... +def warn(msg: str, *args: object) -> None: ... +def error(msg: str, *args: object) -> None: ... +def fatal(msg: str, *args: object) -> None: ... def set_threshold(level: int) -> int: ... def set_verbosity(v: int) -> None: ... diff --git a/typings/distutils-stubs/spawn.pyi b/typings/distutils-stubs/spawn.pyi index 50d89aeb9e..4f849bd2d2 100644 --- a/typings/distutils-stubs/spawn.pyi +++ b/typings/distutils-stubs/spawn.pyi @@ -1,6 +1,7 @@ -from typing import Literal - def spawn( - cmd: list[str], search_path: bool | Literal[0, 1] = 1, verbose: bool | Literal[0, 1] = 0, dry_run: bool | Literal[0, 1] = 0 + cmd: list[str], + search_path: bool = True, + verbose: bool = False, + dry_run: bool = False, ) -> None: ... def find_executable(executable: str, path: str | None = None) -> str | None: ... diff --git a/typings/distutils-stubs/text_file.pyi b/typings/distutils-stubs/text_file.pyi index 54951af7e5..8dce428941 100644 --- a/typings/distutils-stubs/text_file.pyi +++ b/typings/distutils-stubs/text_file.pyi @@ -1,4 +1,4 @@ -from typing import IO, Literal +from typing import IO class TextFile: def __init__( @@ -6,16 +6,18 @@ class TextFile: filename: str | None = None, file: IO[str] | None = None, *, - strip_comments: bool | Literal[0, 1] = ..., - lstrip_ws: bool | Literal[0, 1] = ..., - rstrip_ws: bool | Literal[0, 1] = ..., - skip_blanks: bool | Literal[0, 1] = ..., - join_lines: bool | Literal[0, 1] = ..., - collapse_join: bool | Literal[0, 1] = ..., + strip_comments: bool = ..., + lstrip_ws: bool = ..., + rstrip_ws: bool = ..., + skip_blanks: bool = ..., + join_lines: bool = ..., + collapse_join: bool = ..., ) -> None: ... def open(self, filename: str) -> None: ... def close(self) -> None: ... - def warn(self, msg: str, line: list[int] | tuple[int, int] | int | None = None) -> None: ... + def warn( + self, msg: str, line: list[int] | tuple[int, int] | int | None = None + ) -> None: ... def readline(self) -> str | None: ... def readlines(self) -> list[str]: ... def unreadline(self, line: str) -> str: ... diff --git a/typings/distutils-stubs/util.pyi b/typings/distutils-stubs/util.pyi index 7a01252ea5..b750dfaad0 100644 --- a/typings/distutils-stubs/util.pyi +++ b/typings/distutils-stubs/util.pyi @@ -1,6 +1,6 @@ -from _typeshed import Unused from collections.abc import Callable, Mapping -from typing import Literal + +from _typeshed import Unused from typing_extensions import TypeVarTuple, Unpack _Ts = TypeVarTuple("_Ts") @@ -23,7 +23,7 @@ def execute( verbose: bool = False, dry_run: bool = False, ) -> None: ... -def strtobool(val: str) -> Literal[0, 1]: ... +def strtobool(val: str) -> bool: ... def byte_compile( py_files: list[str], optimize: int = 0, diff --git a/typings/distutils-stubs/version.pyi b/typings/distutils-stubs/version.pyi index 47da65ef87..afb8aa3abe 100644 --- a/typings/distutils-stubs/version.pyi +++ b/typings/distutils-stubs/version.pyi @@ -23,7 +23,7 @@ class StrictVersion(Version): prerelease: tuple[str, int] | None def __init__(self, vstring: str | None = None) -> None: ... def parse(self, vstring: str) -> Self: ... - def __str__(self) -> str: ... # noqa: Y029 + def __str__(self) -> str: ... # noqa: PYI029 def _cmp(self, other: Self | str) -> bool: ... class LooseVersion(Version): @@ -32,5 +32,5 @@ class LooseVersion(Version): version: tuple[str | int, ...] def __init__(self, vstring: str | None = None) -> None: ... def parse(self, vstring: str) -> Self: ... - def __str__(self) -> str: ... # noqa: Y029 + def __str__(self) -> str: ... # noqa: PYI029 def _cmp(self, other: Self | str) -> bool: ... From 13e4bbc24124bc8a7dde5d408dac25706c271aa8 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 17 Oct 2024 17:54:32 -0400 Subject: [PATCH 5/6] Relative distutils imports --- typings/distutils-stubs/bcppcompiler.pyi | 2 +- typings/distutils-stubs/cmd.pyi | 42 ++++++++++----------- typings/distutils-stubs/config.pyi | 3 +- typings/distutils-stubs/core.pyi | 6 +-- typings/distutils-stubs/cygwinccompiler.pyi | 5 ++- typings/distutils-stubs/dist.pyi | 41 ++++++++++---------- typings/distutils-stubs/msvccompiler.pyi | 2 +- typings/distutils-stubs/unixccompiler.pyi | 2 +- 8 files changed, 51 insertions(+), 52 deletions(-) diff --git a/typings/distutils-stubs/bcppcompiler.pyi b/typings/distutils-stubs/bcppcompiler.pyi index 3e432f94b5..036983117c 100644 --- a/typings/distutils-stubs/bcppcompiler.pyi +++ b/typings/distutils-stubs/bcppcompiler.pyi @@ -1,3 +1,3 @@ -from distutils.ccompiler import CCompiler +from .ccompiler import CCompiler class BCPPCompiler(CCompiler): ... diff --git a/typings/distutils-stubs/cmd.pyi b/typings/distutils-stubs/cmd.pyi index a483ba60f3..c9e25b6bd8 100644 --- a/typings/distutils-stubs/cmd.pyi +++ b/typings/distutils-stubs/cmd.pyi @@ -1,31 +1,29 @@ from _typeshed import BytesPath, StrOrBytesPath, StrPath, Unused from abc import abstractmethod from collections.abc import Callable, Iterable -from typing import Any, ClassVar, TypeVar, overload -from distutils.command.bdist import bdist -from distutils.command.bdist_dumb import bdist_dumb -from distutils.command.bdist_rpm import bdist_rpm -from distutils.command.build import build -from distutils.command.build_clib import build_clib -from distutils.command.build_ext import build_ext -from distutils.command.build_py import build_py -from distutils.command.build_scripts import build_scripts -from distutils.command.check import check -from distutils.command.clean import clean -from distutils.command.config import config -from distutils.command.install import install -from distutils.command.install_data import install_data -from distutils.command.install_egg_info import install_egg_info -from distutils.command.install_headers import install_headers -from distutils.command.install_lib import install_lib -from distutils.command.install_scripts import install_scripts -from distutils.command.register import register -from distutils.command.sdist import sdist -from distutils.command.upload import upload -from distutils.dist import Distribution from typing import Any, ClassVar, Literal, TypeVar, overload from typing_extensions import TypeVarTuple, Unpack +from .command.bdist import bdist +from .command.bdist_dumb import bdist_dumb +from .command.bdist_rpm import bdist_rpm +from .command.build import build +from .command.build_clib import build_clib +from .command.build_ext import build_ext +from .command.build_py import build_py +from .command.build_scripts import build_scripts +from .command.check import check +from .command.clean import clean +from .command.config import config +from .command.install import install +from .command.install_data import install_data +from .command.install_egg_info import install_egg_info +from .command.install_headers import install_headers +from .command.install_lib import install_lib +from .command.install_scripts import install_scripts +from .command.register import register +from .command.sdist import sdist +from .command.upload import upload from .dist import Distribution _StrPathT = TypeVar("_StrPathT", bound=StrPath) diff --git a/typings/distutils-stubs/config.pyi b/typings/distutils-stubs/config.pyi index 5814a82841..28ca344d9b 100644 --- a/typings/distutils-stubs/config.pyi +++ b/typings/distutils-stubs/config.pyi @@ -1,7 +1,8 @@ from abc import abstractmethod -from distutils.cmd import Command from typing import ClassVar +from .cmd import Command + DEFAULT_PYPIRC: str class PyPIRCCommand(Command): diff --git a/typings/distutils-stubs/core.pyi b/typings/distutils-stubs/core.pyi index 32695ec2d9..f519706a5d 100644 --- a/typings/distutils-stubs/core.pyi +++ b/typings/distutils-stubs/core.pyi @@ -3,9 +3,9 @@ from typing import Final from _typeshed import Incomplete, StrOrBytesPath -from distutils.cmd import Command as Command -from distutils.dist import Distribution as Distribution -from distutils.extension import Extension as Extension +from .cmd import Command as Command +from .dist import Distribution as Distribution +from .extension import Extension as Extension USAGE: Final[str] diff --git a/typings/distutils-stubs/cygwinccompiler.pyi b/typings/distutils-stubs/cygwinccompiler.pyi index 80924d63e4..20dfabc443 100644 --- a/typings/distutils-stubs/cygwinccompiler.pyi +++ b/typings/distutils-stubs/cygwinccompiler.pyi @@ -1,8 +1,9 @@ -from distutils.unixccompiler import UnixCCompiler -from distutils.version import LooseVersion from re import Pattern from typing import Final, Literal +from .unixccompiler import UnixCCompiler +from .version import LooseVersion + def get_msvcr() -> list[str] | None: ... class CygwinCCompiler(UnixCCompiler): ... diff --git a/typings/distutils-stubs/dist.pyi b/typings/distutils-stubs/dist.pyi index a908efd47b..15f08ba49e 100644 --- a/typings/distutils-stubs/dist.pyi +++ b/typings/distutils-stubs/dist.pyi @@ -1,31 +1,30 @@ from _typeshed import Incomplete, StrOrBytesPath, StrPath, SupportsWrite from collections.abc import Iterable, MutableMapping -from distutils.cmd import Command -from distutils.command.bdist import bdist -from distutils.command.bdist_dumb import bdist_dumb -from distutils.command.bdist_rpm import bdist_rpm -from distutils.command.build import build -from distutils.command.build_clib import build_clib -from distutils.command.build_ext import build_ext -from distutils.command.build_py import build_py -from distutils.command.build_scripts import build_scripts -from distutils.command.check import check -from distutils.command.clean import clean -from distutils.command.config import config -from distutils.command.install import install -from distutils.command.install_data import install_data -from distutils.command.install_egg_info import install_egg_info -from distutils.command.install_headers import install_headers -from distutils.command.install_lib import install_lib -from distutils.command.install_scripts import install_scripts -from distutils.command.register import register -from distutils.command.sdist import sdist -from distutils.command.upload import upload from re import Pattern from typing import IO, ClassVar, Literal, TypeVar, overload from typing_extensions import TypeAlias from .cmd import Command +from .command.bdist import bdist +from .command.bdist_dumb import bdist_dumb +from .command.bdist_rpm import bdist_rpm +from .command.build import build +from .command.build_clib import build_clib +from .command.build_ext import build_ext +from .command.build_py import build_py +from .command.build_scripts import build_scripts +from .command.check import check +from .command.clean import clean +from .command.config import config +from .command.install import install +from .command.install_data import install_data +from .command.install_egg_info import install_egg_info +from .command.install_headers import install_headers +from .command.install_lib import install_lib +from .command.install_scripts import install_scripts +from .command.register import register +from .command.sdist import sdist +from .command.upload import upload command_re: Pattern[str] diff --git a/typings/distutils-stubs/msvccompiler.pyi b/typings/distutils-stubs/msvccompiler.pyi index 80872a6b73..26289a9a1f 100644 --- a/typings/distutils-stubs/msvccompiler.pyi +++ b/typings/distutils-stubs/msvccompiler.pyi @@ -1,3 +1,3 @@ -from distutils.ccompiler import CCompiler +from .ccompiler import CCompiler class MSVCCompiler(CCompiler): ... diff --git a/typings/distutils-stubs/unixccompiler.pyi b/typings/distutils-stubs/unixccompiler.pyi index e1d443471a..0a3ec2321c 100644 --- a/typings/distutils-stubs/unixccompiler.pyi +++ b/typings/distutils-stubs/unixccompiler.pyi @@ -1,3 +1,3 @@ -from distutils.ccompiler import CCompiler +from .ccompiler import CCompiler class UnixCCompiler(CCompiler): ... From 7ea98d5c596566bbe22ef474404e0c1dc76bee60 Mon Sep 17 00:00:00 2001 From: Avasam Date: Thu, 17 Oct 2024 18:42:35 -0400 Subject: [PATCH 6/6] Reformatted distutils-stubs --- typings/distutils-stubs/_modified.pyi | 16 +- typings/distutils-stubs/archive_util.pyi | 7 +- typings/distutils-stubs/cmd.pyi | 157 +++++++++---- typings/distutils-stubs/command/bdist.pyi | 3 +- .../distutils-stubs/command/bdist_dumb.pyi | 3 +- typings/distutils-stubs/command/bdist_rpm.pyi | 3 +- typings/distutils-stubs/command/build.pyi | 3 +- .../distutils-stubs/command/build_clib.pyi | 3 +- typings/distutils-stubs/command/build_ext.pyi | 3 +- typings/distutils-stubs/command/build_py.pyi | 3 +- .../distutils-stubs/command/build_scripts.pyi | 3 +- typings/distutils-stubs/command/clean.pyi | 3 +- typings/distutils-stubs/command/install.pyi | 3 +- .../distutils-stubs/command/install_data.pyi | 3 +- .../command/install_egg_info.pyi | 3 +- .../command/install_headers.pyi | 3 +- .../distutils-stubs/command/install_lib.pyi | 3 +- .../command/install_scripts.pyi | 3 +- typings/distutils-stubs/command/register.pyi | 3 +- typings/distutils-stubs/command/sdist.pyi | 3 +- typings/distutils-stubs/command/upload.pyi | 3 +- typings/distutils-stubs/dep_util.pyi | 6 +- typings/distutils-stubs/dist.pyi | 212 +++++++++++++----- typings/distutils-stubs/sysconfig.pyi | 9 +- typings/distutils-stubs/version.pyi | 1 + 25 files changed, 343 insertions(+), 119 deletions(-) diff --git a/typings/distutils-stubs/_modified.pyi b/typings/distutils-stubs/_modified.pyi index e825ba0db5..84444dc04a 100644 --- a/typings/distutils-stubs/_modified.pyi +++ b/typings/distutils-stubs/_modified.pyi @@ -1,17 +1,25 @@ -from _typeshed import StrOrBytesPath from collections.abc import Callable, Iterable from typing import Literal, TypeVar +from _typeshed import StrOrBytesPath + _SourcesT = TypeVar("_SourcesT", bound=StrOrBytesPath) _TargetsT = TypeVar("_TargetsT", bound=StrOrBytesPath) def newer(source: StrOrBytesPath, target: StrOrBytesPath) -> bool: ... def newer_pairwise( - sources: Iterable[_SourcesT], targets: Iterable[_TargetsT], newer: Callable[[_SourcesT, _TargetsT], bool] = newer + sources: Iterable[_SourcesT], + targets: Iterable[_TargetsT], + newer: Callable[[_SourcesT, _TargetsT], bool] = newer, ) -> tuple[list[_SourcesT], list[_TargetsT]]: ... def newer_group( - sources: Iterable[StrOrBytesPath], target: StrOrBytesPath, missing: Literal["error", "ignore", "newer"] = "error" + sources: Iterable[StrOrBytesPath], + target: StrOrBytesPath, + missing: Literal["error", "ignore", "newer"] = "error", ) -> bool: ... def newer_pairwise_group( - sources: Iterable[_SourcesT], targets: Iterable[_TargetsT], *, newer: Callable[[_SourcesT, _TargetsT], bool] = newer + sources: Iterable[_SourcesT], + targets: Iterable[_TargetsT], + *, + newer: Callable[[_SourcesT, _TargetsT], bool] = newer, ) -> tuple[list[_SourcesT], list[_TargetsT]]: ... diff --git a/typings/distutils-stubs/archive_util.pyi b/typings/distutils-stubs/archive_util.pyi index c2b9566e12..ad37d64ce8 100644 --- a/typings/distutils-stubs/archive_util.pyi +++ b/typings/distutils-stubs/archive_util.pyi @@ -1,6 +1,7 @@ -from _typeshed import StrOrBytesPath, StrPath from typing import Literal, overload +from _typeshed import StrOrBytesPath, StrPath + @overload def make_archive( base_name: str, @@ -32,4 +33,6 @@ def make_tarball( owner: str | None = None, group: str | None = None, ) -> str: ... -def make_zipfile(base_name: str, base_dir: str, verbose: bool = False, dry_run: bool = False) -> str: ... +def make_zipfile( + base_name: str, base_dir: str, verbose: bool = False, dry_run: bool = False +) -> str: ... diff --git a/typings/distutils-stubs/cmd.pyi b/typings/distutils-stubs/cmd.pyi index c9e25b6bd8..15f59e6d46 100644 --- a/typings/distutils-stubs/cmd.pyi +++ b/typings/distutils-stubs/cmd.pyi @@ -1,7 +1,8 @@ -from _typeshed import BytesPath, StrOrBytesPath, StrPath, Unused from abc import abstractmethod from collections.abc import Callable, Iterable from typing import Any, ClassVar, Literal, TypeVar, overload + +from _typeshed import BytesPath, StrOrBytesPath, StrPath, Unused from typing_extensions import TypeVarTuple, Unpack from .command.bdist import bdist @@ -51,82 +52,140 @@ class Command: 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 set_undefined_options( + self, src_cmd: str, *option_pairs: tuple[str, str] + ) -> None: ... # NOTE: This list comes directly from the distutils/command folder. Minus bdist_msi and bdist_wininst. @overload - def get_finalized_command(self, command: Literal["bdist"], create: bool = True) -> bdist: ... + def get_finalized_command( + self, command: Literal["bdist"], create: bool = True + ) -> bdist: ... @overload - def get_finalized_command(self, command: Literal["bdist_dumb"], create: bool = True) -> bdist_dumb: ... + def get_finalized_command( + self, command: Literal["bdist_dumb"], create: bool = True + ) -> bdist_dumb: ... @overload - def get_finalized_command(self, command: Literal["bdist_rpm"], create: bool = True) -> bdist_rpm: ... + def get_finalized_command( + self, command: Literal["bdist_rpm"], create: bool = True + ) -> bdist_rpm: ... @overload - def get_finalized_command(self, command: Literal["build"], create: bool = True) -> build: ... + def get_finalized_command( + self, command: Literal["build"], create: bool = True + ) -> build: ... @overload - def get_finalized_command(self, command: Literal["build_clib"], create: bool = True) -> build_clib: ... + def get_finalized_command( + self, command: Literal["build_clib"], create: bool = True + ) -> build_clib: ... @overload - def get_finalized_command(self, command: Literal["build_ext"], create: bool = True) -> build_ext: ... + def get_finalized_command( + self, command: Literal["build_ext"], create: bool = True + ) -> build_ext: ... @overload - def get_finalized_command(self, command: Literal["build_py"], create: bool = True) -> build_py: ... + def get_finalized_command( + self, command: Literal["build_py"], create: bool = True + ) -> build_py: ... @overload - def get_finalized_command(self, command: Literal["build_scripts"], create: bool = True) -> build_scripts: ... + def get_finalized_command( + self, command: Literal["build_scripts"], create: bool = True + ) -> build_scripts: ... @overload - def get_finalized_command(self, command: Literal["check"], create: bool = True) -> check: ... + def get_finalized_command( + self, command: Literal["check"], create: bool = True + ) -> check: ... @overload - def get_finalized_command(self, command: Literal["clean"], create: bool = True) -> clean: ... + def get_finalized_command( + self, command: Literal["clean"], create: bool = True + ) -> clean: ... @overload - def get_finalized_command(self, command: Literal["config"], create: bool = True) -> config: ... + def get_finalized_command( + self, command: Literal["config"], create: bool = True + ) -> config: ... @overload - def get_finalized_command(self, command: Literal["install"], create: bool = True) -> install: ... + def get_finalized_command( + self, command: Literal["install"], create: bool = True + ) -> install: ... @overload - def get_finalized_command(self, command: Literal["install_data"], create: bool = True) -> install_data: ... + def get_finalized_command( + self, command: Literal["install_data"], create: bool = True + ) -> install_data: ... @overload def get_finalized_command( self, command: Literal["install_egg_info"], create: bool = True ) -> install_egg_info: ... @overload - def get_finalized_command(self, command: Literal["install_headers"], create: bool = True) -> install_headers: ... + def get_finalized_command( + self, command: Literal["install_headers"], create: bool = True + ) -> install_headers: ... @overload - def get_finalized_command(self, command: Literal["install_lib"], create: bool = True) -> install_lib: ... + def get_finalized_command( + self, command: Literal["install_lib"], create: bool = True + ) -> install_lib: ... @overload - def get_finalized_command(self, command: Literal["install_scripts"], create: bool = True) -> install_scripts: ... + def get_finalized_command( + self, command: Literal["install_scripts"], create: bool = True + ) -> install_scripts: ... @overload - def get_finalized_command(self, command: Literal["register"], create: bool = True) -> register: ... + def get_finalized_command( + self, command: Literal["register"], create: bool = True + ) -> register: ... @overload - def get_finalized_command(self, command: Literal["sdist"], create: bool = True) -> sdist: ... + def get_finalized_command( + self, command: Literal["sdist"], create: bool = True + ) -> sdist: ... @overload - def get_finalized_command(self, command: Literal["upload"], create: bool = True) -> upload: ... + def get_finalized_command( + self, command: Literal["upload"], create: bool = True + ) -> upload: ... @overload def get_finalized_command(self, command: str, create: bool = True) -> Command: ... @overload - def reinitialize_command(self, command: Literal["bdist"], reinit_subcommands: bool = False) -> bdist: ... + def reinitialize_command( + self, command: Literal["bdist"], reinit_subcommands: bool = False + ) -> bdist: ... @overload def reinitialize_command( self, command: Literal["bdist_dumb"], reinit_subcommands: bool = False ) -> bdist_dumb: ... @overload - def reinitialize_command(self, command: Literal["bdist_rpm"], reinit_subcommands: bool = False) -> bdist_rpm: ... + def reinitialize_command( + self, command: Literal["bdist_rpm"], reinit_subcommands: bool = False + ) -> bdist_rpm: ... @overload - def reinitialize_command(self, command: Literal["build"], reinit_subcommands: bool = False) -> build: ... + def reinitialize_command( + self, command: Literal["build"], reinit_subcommands: bool = False + ) -> build: ... @overload def reinitialize_command( self, command: Literal["build_clib"], reinit_subcommands: bool = False ) -> build_clib: ... @overload - def reinitialize_command(self, command: Literal["build_ext"], reinit_subcommands: bool = False) -> build_ext: ... + def reinitialize_command( + self, command: Literal["build_ext"], reinit_subcommands: bool = False + ) -> build_ext: ... @overload - def reinitialize_command(self, command: Literal["build_py"], reinit_subcommands: bool = False) -> build_py: ... + def reinitialize_command( + self, command: Literal["build_py"], reinit_subcommands: bool = False + ) -> build_py: ... @overload def reinitialize_command( self, command: Literal["build_scripts"], reinit_subcommands: bool = False ) -> build_scripts: ... @overload - def reinitialize_command(self, command: Literal["check"], reinit_subcommands: bool = False) -> check: ... + def reinitialize_command( + self, command: Literal["check"], reinit_subcommands: bool = False + ) -> check: ... @overload - def reinitialize_command(self, command: Literal["clean"], reinit_subcommands: bool = False) -> clean: ... + def reinitialize_command( + self, command: Literal["clean"], reinit_subcommands: bool = False + ) -> clean: ... @overload - def reinitialize_command(self, command: Literal["config"], reinit_subcommands: bool = False) -> config: ... + def reinitialize_command( + self, command: Literal["config"], reinit_subcommands: bool = False + ) -> config: ... @overload - def reinitialize_command(self, command: Literal["install"], reinit_subcommands: bool = False) -> install: ... + def reinitialize_command( + self, command: Literal["install"], reinit_subcommands: bool = False + ) -> install: ... @overload def reinitialize_command( self, command: Literal["install_data"], reinit_subcommands: bool = False @@ -148,20 +207,34 @@ class Command: self, command: Literal["install_scripts"], reinit_subcommands: bool = False ) -> install_scripts: ... @overload - def reinitialize_command(self, command: Literal["register"], reinit_subcommands: bool = False) -> register: ... + def reinitialize_command( + self, command: Literal["register"], reinit_subcommands: bool = False + ) -> register: ... @overload - def reinitialize_command(self, command: Literal["sdist"], reinit_subcommands: bool = False) -> sdist: ... + def reinitialize_command( + self, command: Literal["sdist"], reinit_subcommands: bool = False + ) -> sdist: ... @overload - def reinitialize_command(self, command: Literal["upload"], reinit_subcommands: bool = False) -> upload: ... + def reinitialize_command( + self, command: Literal["upload"], reinit_subcommands: bool = False + ) -> upload: ... @overload - def reinitialize_command(self, command: str, reinit_subcommands: bool = False) -> Command: ... + def reinitialize_command( + self, command: str, reinit_subcommands: bool = False + ) -> Command: ... @overload - def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool = False) -> _CommandT: ... + 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: ... def execute( - self, func: Callable[[Unpack[_Ts]], Unused], args: tuple[Unpack[_Ts]], msg: str | None = None, level: int = 1 + self, + func: Callable[[Unpack[_Ts]], Unused], + args: tuple[Unpack[_Ts]], + msg: str | None = None, + level: int = 1, ) -> None: ... def mkpath(self, name: str, mode: int = 0o777) -> None: ... @overload @@ -194,10 +267,16 @@ class Command: level: Unused = 1, ) -> list[str]: ... @overload - def move_file(self, src: StrPath, dst: _StrPathT, level: Unused = 1) -> _StrPathT | str: ... + def move_file( + self, src: StrPath, dst: _StrPathT, level: Unused = 1 + ) -> _StrPathT | str: ... @overload - def move_file(self, src: BytesPath, dst: _BytesPathT, level: Unused = 1) -> _BytesPathT | bytes: ... - def spawn(self, cmd: Iterable[str], search_path: bool = True, level: Unused = 1) -> None: ... + def move_file( + self, src: BytesPath, dst: _BytesPathT, level: Unused = 1 + ) -> _BytesPathT | bytes: ... + def spawn( + self, cmd: Iterable[str], search_path: bool = True, level: Unused = 1 + ) -> None: ... @overload def make_archive( self, diff --git a/typings/distutils-stubs/command/bdist.pyi b/typings/distutils-stubs/command/bdist.pyi index 0d69929831..43e6ece30e 100644 --- a/typings/distutils-stubs/command/bdist.pyi +++ b/typings/distutils-stubs/command/bdist.pyi @@ -1,6 +1,7 @@ -from _typeshed import Unused from collections.abc import Callable from typing import ClassVar + +from _typeshed import Unused from typing_extensions import deprecated from ..cmd import Command diff --git a/typings/distutils-stubs/command/bdist_dumb.pyi b/typings/distutils-stubs/command/bdist_dumb.pyi index 297a0c39ed..d7943b76d7 100644 --- a/typings/distutils-stubs/command/bdist_dumb.pyi +++ b/typings/distutils-stubs/command/bdist_dumb.pyi @@ -1,6 +1,7 @@ -from _typeshed import Incomplete from typing import ClassVar +from _typeshed import Incomplete + from ..cmd import Command class bdist_dumb(Command): diff --git a/typings/distutils-stubs/command/bdist_rpm.pyi b/typings/distutils-stubs/command/bdist_rpm.pyi index 83b4161094..eca2780b55 100644 --- a/typings/distutils-stubs/command/bdist_rpm.pyi +++ b/typings/distutils-stubs/command/bdist_rpm.pyi @@ -1,6 +1,7 @@ -from _typeshed import Incomplete from typing import ClassVar +from _typeshed import Incomplete + from ..cmd import Command class bdist_rpm(Command): diff --git a/typings/distutils-stubs/command/build.pyi b/typings/distutils-stubs/command/build.pyi index a1c00b5c81..59cbdf3d18 100644 --- a/typings/distutils-stubs/command/build.pyi +++ b/typings/distutils-stubs/command/build.pyi @@ -1,7 +1,8 @@ -from _typeshed import Incomplete, Unused from collections.abc import Callable from typing import ClassVar +from _typeshed import Incomplete, Unused + from ..cmd import Command def show_compilers() -> None: ... diff --git a/typings/distutils-stubs/command/build_clib.pyi b/typings/distutils-stubs/command/build_clib.pyi index 687cb53450..75b78a718f 100644 --- a/typings/distutils-stubs/command/build_clib.pyi +++ b/typings/distutils-stubs/command/build_clib.pyi @@ -1,7 +1,8 @@ -from _typeshed import Incomplete, Unused from collections.abc import Callable from typing import ClassVar +from _typeshed import Incomplete, Unused + from ..cmd import Command class build_clib(Command): diff --git a/typings/distutils-stubs/command/build_ext.pyi b/typings/distutils-stubs/command/build_ext.pyi index 49c7f19485..2b8c49788f 100644 --- a/typings/distutils-stubs/command/build_ext.pyi +++ b/typings/distutils-stubs/command/build_ext.pyi @@ -1,7 +1,8 @@ -from _typeshed import Incomplete, Unused from collections.abc import Callable from typing import ClassVar +from _typeshed import Incomplete, Unused + from ..cmd import Command from ..extension import Extension diff --git a/typings/distutils-stubs/command/build_py.pyi b/typings/distutils-stubs/command/build_py.pyi index 6ad82d005e..628ab5347f 100644 --- a/typings/distutils-stubs/command/build_py.pyi +++ b/typings/distutils-stubs/command/build_py.pyi @@ -1,6 +1,7 @@ -from _typeshed import Incomplete from typing import ClassVar +from _typeshed import Incomplete + from ..cmd import Command class build_py(Command): diff --git a/typings/distutils-stubs/command/build_scripts.pyi b/typings/distutils-stubs/command/build_scripts.pyi index 74ca2cacd9..5ac864d487 100644 --- a/typings/distutils-stubs/command/build_scripts.pyi +++ b/typings/distutils-stubs/command/build_scripts.pyi @@ -1,6 +1,7 @@ -from _typeshed import Incomplete from typing import ClassVar +from _typeshed import Incomplete + from ..cmd import Command first_line_re: Incomplete diff --git a/typings/distutils-stubs/command/clean.pyi b/typings/distutils-stubs/command/clean.pyi index 0f3768d6dc..2b78d86031 100644 --- a/typings/distutils-stubs/command/clean.pyi +++ b/typings/distutils-stubs/command/clean.pyi @@ -1,6 +1,7 @@ -from _typeshed import Incomplete from typing import ClassVar +from _typeshed import Incomplete + from ..cmd import Command class clean(Command): diff --git a/typings/distutils-stubs/command/install.pyi b/typings/distutils-stubs/command/install.pyi index 8e092f7d6c..798e30ae27 100644 --- a/typings/distutils-stubs/command/install.pyi +++ b/typings/distutils-stubs/command/install.pyi @@ -1,6 +1,7 @@ -from _typeshed import Incomplete from typing import ClassVar +from _typeshed import Incomplete + from ..cmd import Command class install(Command): diff --git a/typings/distutils-stubs/command/install_data.pyi b/typings/distutils-stubs/command/install_data.pyi index 609de62b04..8cc23f08db 100644 --- a/typings/distutils-stubs/command/install_data.pyi +++ b/typings/distutils-stubs/command/install_data.pyi @@ -1,6 +1,7 @@ -from _typeshed import Incomplete from typing import ClassVar +from _typeshed import Incomplete + from ..cmd import Command class install_data(Command): diff --git a/typings/distutils-stubs/command/install_egg_info.pyi b/typings/distutils-stubs/command/install_egg_info.pyi index 75bb906ce5..fdc0cf982a 100644 --- a/typings/distutils-stubs/command/install_egg_info.pyi +++ b/typings/distutils-stubs/command/install_egg_info.pyi @@ -1,6 +1,7 @@ -from _typeshed import Incomplete from typing import ClassVar +from _typeshed import Incomplete + from ..cmd import Command class install_egg_info(Command): diff --git a/typings/distutils-stubs/command/install_headers.pyi b/typings/distutils-stubs/command/install_headers.pyi index 3caad8a07d..dc1243a3f7 100644 --- a/typings/distutils-stubs/command/install_headers.pyi +++ b/typings/distutils-stubs/command/install_headers.pyi @@ -1,6 +1,7 @@ -from _typeshed import Incomplete from typing import ClassVar +from _typeshed import Incomplete + from ..cmd import Command class install_headers(Command): diff --git a/typings/distutils-stubs/command/install_lib.pyi b/typings/distutils-stubs/command/install_lib.pyi index 7edc148be9..1189464ae1 100644 --- a/typings/distutils-stubs/command/install_lib.pyi +++ b/typings/distutils-stubs/command/install_lib.pyi @@ -1,6 +1,7 @@ -from _typeshed import Incomplete from typing import ClassVar +from _typeshed import Incomplete + from ..cmd import Command class install_lib(Command): diff --git a/typings/distutils-stubs/command/install_scripts.pyi b/typings/distutils-stubs/command/install_scripts.pyi index b9eab32f9d..a87284e842 100644 --- a/typings/distutils-stubs/command/install_scripts.pyi +++ b/typings/distutils-stubs/command/install_scripts.pyi @@ -1,6 +1,7 @@ -from _typeshed import Incomplete from typing import ClassVar +from _typeshed import Incomplete + from ..cmd import Command class install_scripts(Command): diff --git a/typings/distutils-stubs/command/register.pyi b/typings/distutils-stubs/command/register.pyi index 6f5901ffbc..bb9d6c2e38 100644 --- a/typings/distutils-stubs/command/register.pyi +++ b/typings/distutils-stubs/command/register.pyi @@ -1,7 +1,8 @@ -from _typeshed import Incomplete from collections.abc import Callable from typing import Any, ClassVar +from _typeshed import Incomplete + from ..config import PyPIRCCommand class register(PyPIRCCommand): diff --git a/typings/distutils-stubs/command/sdist.pyi b/typings/distutils-stubs/command/sdist.pyi index a84fbef2a6..94a80cc8cb 100644 --- a/typings/distutils-stubs/command/sdist.pyi +++ b/typings/distutils-stubs/command/sdist.pyi @@ -1,7 +1,8 @@ -from _typeshed import Incomplete, Unused from collections.abc import Callable from typing import ClassVar +from _typeshed import Incomplete, Unused + from ..cmd import Command def show_formats() -> None: ... diff --git a/typings/distutils-stubs/command/upload.pyi b/typings/distutils-stubs/command/upload.pyi index afcfbaf486..a78f777ba7 100644 --- a/typings/distutils-stubs/command/upload.pyi +++ b/typings/distutils-stubs/command/upload.pyi @@ -1,6 +1,7 @@ -from _typeshed import Incomplete from typing import ClassVar +from _typeshed import Incomplete + from ..config import PyPIRCCommand class upload(PyPIRCCommand): diff --git a/typings/distutils-stubs/dep_util.pyi b/typings/distutils-stubs/dep_util.pyi index 88cd92f001..518d6c7ebe 100644 --- a/typings/distutils-stubs/dep_util.pyi +++ b/typings/distutils-stubs/dep_util.pyi @@ -1 +1,5 @@ -from ._modified import newer as newer, newer_group as newer_group, newer_pairwise as newer_pairwise +from ._modified import ( + newer as newer, + newer_group as newer_group, + newer_pairwise as newer_pairwise, +) diff --git a/typings/distutils-stubs/dist.pyi b/typings/distutils-stubs/dist.pyi index 15f08ba49e..4118b1bc90 100644 --- a/typings/distutils-stubs/dist.pyi +++ b/typings/distutils-stubs/dist.pyi @@ -1,7 +1,8 @@ -from _typeshed import Incomplete, StrOrBytesPath, StrPath, SupportsWrite from collections.abc import Iterable, MutableMapping from re import Pattern from typing import IO, ClassVar, Literal, TypeVar, overload + +from _typeshed import Incomplete, StrOrBytesPath, StrPath, SupportsWrite from typing_extensions import TypeAlias from .cmd import Command @@ -28,7 +29,9 @@ from .command.upload import upload command_re: Pattern[str] -_OptionsList: TypeAlias = list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] +_OptionsList: TypeAlias = list[ + tuple[str, str | None, str, int] | tuple[str, str | None, str] +] _CommandT = TypeVar("_CommandT", bound=Command) class DistributionMetadata: @@ -81,7 +84,9 @@ class DistributionMetadata: class Distribution: cmdclass: dict[str, type[Command]] metadata: DistributionMetadata - def __init__(self, attrs: MutableMapping[str, Incomplete] | 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: ... global_options: ClassVar[_OptionsList] @@ -114,7 +119,10 @@ class Distribution: have_run: dict[str, bool] want_user_cfg: bool def dump_option_dicts( - self, header: Incomplete | None = None, commands: Incomplete | None = None, indent: str = "" + self, + header: Incomplete | None = None, + commands: Incomplete | None = None, + indent: str = "", ) -> None: ... def find_config_files(self): ... commands: Incomplete @@ -127,50 +135,94 @@ class Distribution: def get_command_packages(self): ... # NOTE: This list comes directly from the distutils/command folder. Minus bdist_msi and bdist_wininst. @overload - def get_command_obj(self, command: Literal["bdist"], create: Literal[True] = True) -> bdist: ... + def get_command_obj( + self, command: Literal["bdist"], create: Literal[True] = True + ) -> bdist: ... @overload - def get_command_obj(self, command: Literal["bdist_dumb"], create: Literal[True] = True) -> bdist_dumb: ... + def get_command_obj( + self, command: Literal["bdist_dumb"], create: Literal[True] = True + ) -> bdist_dumb: ... @overload - def get_command_obj(self, command: Literal["bdist_rpm"], create: Literal[True] = True) -> bdist_rpm: ... + def get_command_obj( + self, command: Literal["bdist_rpm"], create: Literal[True] = True + ) -> bdist_rpm: ... @overload - def get_command_obj(self, command: Literal["build"], create: Literal[True] = True) -> build: ... + def get_command_obj( + self, command: Literal["build"], create: Literal[True] = True + ) -> build: ... @overload - def get_command_obj(self, command: Literal["build_clib"], create: Literal[True] = True) -> build_clib: ... + def get_command_obj( + self, command: Literal["build_clib"], create: Literal[True] = True + ) -> build_clib: ... @overload - def get_command_obj(self, command: Literal["build_ext"], create: Literal[True] = True) -> build_ext: ... + def get_command_obj( + self, command: Literal["build_ext"], create: Literal[True] = True + ) -> build_ext: ... @overload - def get_command_obj(self, command: Literal["build_py"], create: Literal[True] = True) -> build_py: ... + def get_command_obj( + self, command: Literal["build_py"], create: Literal[True] = True + ) -> build_py: ... @overload - def get_command_obj(self, command: Literal["build_scripts"], create: Literal[True] = True) -> build_scripts: ... + def get_command_obj( + self, command: Literal["build_scripts"], create: Literal[True] = True + ) -> build_scripts: ... @overload - def get_command_obj(self, command: Literal["check"], create: Literal[True] = True) -> check: ... + def get_command_obj( + self, command: Literal["check"], create: Literal[True] = True + ) -> check: ... @overload - def get_command_obj(self, command: Literal["clean"], create: Literal[True] = True) -> clean: ... + def get_command_obj( + self, command: Literal["clean"], create: Literal[True] = True + ) -> clean: ... @overload - def get_command_obj(self, command: Literal["config"], create: Literal[True] = True) -> config: ... + def get_command_obj( + self, command: Literal["config"], create: Literal[True] = True + ) -> config: ... @overload - def get_command_obj(self, command: Literal["install"], create: Literal[True] = True) -> install: ... + def get_command_obj( + self, command: Literal["install"], create: Literal[True] = True + ) -> install: ... @overload - def get_command_obj(self, command: Literal["install_data"], create: Literal[True] = True) -> install_data: ... + def get_command_obj( + self, command: Literal["install_data"], create: Literal[True] = True + ) -> install_data: ... @overload - def get_command_obj(self, command: Literal["install_egg_info"], create: Literal[True] = True) -> install_egg_info: ... + def get_command_obj( + self, command: Literal["install_egg_info"], create: Literal[True] = True + ) -> install_egg_info: ... @overload - def get_command_obj(self, command: Literal["install_headers"], create: Literal[True] = True) -> install_headers: ... + def get_command_obj( + self, command: Literal["install_headers"], create: Literal[True] = True + ) -> install_headers: ... @overload - def get_command_obj(self, command: Literal["install_lib"], create: Literal[True] = True) -> install_lib: ... + def get_command_obj( + self, command: Literal["install_lib"], create: Literal[True] = True + ) -> install_lib: ... @overload - def get_command_obj(self, command: Literal["install_scripts"], create: Literal[True] = True) -> install_scripts: ... + def get_command_obj( + self, command: Literal["install_scripts"], create: Literal[True] = True + ) -> install_scripts: ... @overload - def get_command_obj(self, command: Literal["register"], create: Literal[True] = True) -> register: ... + def get_command_obj( + self, command: Literal["register"], create: Literal[True] = True + ) -> register: ... @overload - def get_command_obj(self, command: Literal["sdist"], create: Literal[True] = True) -> sdist: ... + def get_command_obj( + self, command: Literal["sdist"], create: Literal[True] = True + ) -> sdist: ... @overload - def get_command_obj(self, command: Literal["upload"], create: Literal[True] = True) -> upload: ... + def get_command_obj( + self, command: Literal["upload"], create: Literal[True] = True + ) -> upload: ... @overload - def get_command_obj(self, command: str, create: Literal[True] = True) -> Command: ... + def get_command_obj( + self, command: str, create: Literal[True] = True + ) -> Command: ... # Not replicating the overloads for "Command | None", user may use "isinstance" @overload - def get_command_obj(self, command: str, create: Literal[False]) -> Command | None: ... + def get_command_obj( + self, command: str, create: Literal[False] + ) -> Command | None: ... @overload def get_command_class(self, command: Literal["bdist"]) -> type[bdist]: ... @overload @@ -186,7 +238,9 @@ class Distribution: @overload def get_command_class(self, command: Literal["build_py"]) -> type[build_py]: ... @overload - def get_command_class(self, command: Literal["build_scripts"]) -> type[build_scripts]: ... + def get_command_class( + self, command: Literal["build_scripts"] + ) -> type[build_scripts]: ... @overload def get_command_class(self, command: Literal["check"]) -> type[check]: ... @overload @@ -196,15 +250,25 @@ class Distribution: @overload def get_command_class(self, command: Literal["install"]) -> type[install]: ... @overload - def get_command_class(self, command: Literal["install_data"]) -> type[install_data]: ... + def get_command_class( + self, command: Literal["install_data"] + ) -> type[install_data]: ... @overload - def get_command_class(self, command: Literal["install_egg_info"]) -> type[install_egg_info]: ... + def get_command_class( + self, command: Literal["install_egg_info"] + ) -> type[install_egg_info]: ... @overload - def get_command_class(self, command: Literal["install_headers"]) -> type[install_headers]: ... + def get_command_class( + self, command: Literal["install_headers"] + ) -> type[install_headers]: ... @overload - def get_command_class(self, command: Literal["install_lib"]) -> type[install_lib]: ... + def get_command_class( + self, command: Literal["install_lib"] + ) -> type[install_lib]: ... @overload - def get_command_class(self, command: Literal["install_scripts"]) -> type[install_scripts]: ... + def get_command_class( + self, command: Literal["install_scripts"] + ) -> type[install_scripts]: ... @overload def get_command_class(self, command: Literal["register"]) -> type[register]: ... @overload @@ -214,51 +278,93 @@ class Distribution: @overload def get_command_class(self, command: str) -> type[Command]: ... @overload - def reinitialize_command(self, command: Literal["bdist"], reinit_subcommands: bool = False) -> bdist: ... + def reinitialize_command( + self, command: Literal["bdist"], reinit_subcommands: bool = False + ) -> bdist: ... @overload - def reinitialize_command(self, command: Literal["bdist_dumb"], reinit_subcommands: bool = False) -> bdist_dumb: ... + def reinitialize_command( + self, command: Literal["bdist_dumb"], reinit_subcommands: bool = False + ) -> bdist_dumb: ... @overload - def reinitialize_command(self, command: Literal["bdist_rpm"], reinit_subcommands: bool = False) -> bdist_rpm: ... + def reinitialize_command( + self, command: Literal["bdist_rpm"], reinit_subcommands: bool = False + ) -> bdist_rpm: ... @overload - def reinitialize_command(self, command: Literal["build"], reinit_subcommands: bool = False) -> build: ... + def reinitialize_command( + self, command: Literal["build"], reinit_subcommands: bool = False + ) -> build: ... @overload - def reinitialize_command(self, command: Literal["build_clib"], reinit_subcommands: bool = False) -> build_clib: ... + def reinitialize_command( + self, command: Literal["build_clib"], reinit_subcommands: bool = False + ) -> build_clib: ... @overload - def reinitialize_command(self, command: Literal["build_ext"], reinit_subcommands: bool = False) -> build_ext: ... + def reinitialize_command( + self, command: Literal["build_ext"], reinit_subcommands: bool = False + ) -> build_ext: ... @overload - def reinitialize_command(self, command: Literal["build_py"], reinit_subcommands: bool = False) -> build_py: ... + def reinitialize_command( + self, command: Literal["build_py"], reinit_subcommands: bool = False + ) -> build_py: ... @overload - def reinitialize_command(self, command: Literal["build_scripts"], reinit_subcommands: bool = False) -> build_scripts: ... + def reinitialize_command( + self, command: Literal["build_scripts"], reinit_subcommands: bool = False + ) -> build_scripts: ... @overload - def reinitialize_command(self, command: Literal["check"], reinit_subcommands: bool = False) -> check: ... + def reinitialize_command( + self, command: Literal["check"], reinit_subcommands: bool = False + ) -> check: ... @overload - def reinitialize_command(self, command: Literal["clean"], reinit_subcommands: bool = False) -> clean: ... + def reinitialize_command( + self, command: Literal["clean"], reinit_subcommands: bool = False + ) -> clean: ... @overload - def reinitialize_command(self, command: Literal["config"], reinit_subcommands: bool = False) -> config: ... + def reinitialize_command( + self, command: Literal["config"], reinit_subcommands: bool = False + ) -> config: ... @overload - def reinitialize_command(self, command: Literal["install"], reinit_subcommands: bool = False) -> install: ... + def reinitialize_command( + self, command: Literal["install"], reinit_subcommands: bool = False + ) -> install: ... @overload - def reinitialize_command(self, command: Literal["install_data"], reinit_subcommands: bool = False) -> install_data: ... + def reinitialize_command( + self, command: Literal["install_data"], reinit_subcommands: bool = False + ) -> install_data: ... @overload def reinitialize_command( self, command: Literal["install_egg_info"], reinit_subcommands: bool = False ) -> install_egg_info: ... @overload - def reinitialize_command(self, command: Literal["install_headers"], reinit_subcommands: bool = False) -> install_headers: ... + def reinitialize_command( + self, command: Literal["install_headers"], reinit_subcommands: bool = False + ) -> install_headers: ... @overload - def reinitialize_command(self, command: Literal["install_lib"], reinit_subcommands: bool = False) -> install_lib: ... + def reinitialize_command( + self, command: Literal["install_lib"], reinit_subcommands: bool = False + ) -> install_lib: ... @overload - def reinitialize_command(self, command: Literal["install_scripts"], reinit_subcommands: bool = False) -> install_scripts: ... + def reinitialize_command( + self, command: Literal["install_scripts"], reinit_subcommands: bool = False + ) -> install_scripts: ... @overload - def reinitialize_command(self, command: Literal["register"], reinit_subcommands: bool = False) -> register: ... + def reinitialize_command( + self, command: Literal["register"], reinit_subcommands: bool = False + ) -> register: ... @overload - def reinitialize_command(self, command: Literal["sdist"], reinit_subcommands: bool = False) -> sdist: ... + def reinitialize_command( + self, command: Literal["sdist"], reinit_subcommands: bool = False + ) -> sdist: ... @overload - def reinitialize_command(self, command: Literal["upload"], reinit_subcommands: bool = False) -> upload: ... + def reinitialize_command( + self, command: Literal["upload"], reinit_subcommands: bool = False + ) -> upload: ... @overload - def reinitialize_command(self, command: str, reinit_subcommands: bool = False) -> Command: ... + def reinitialize_command( + self, command: str, reinit_subcommands: bool = False + ) -> Command: ... @overload - def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool = False) -> _CommandT: ... + def reinitialize_command( + self, command: _CommandT, reinit_subcommands: bool = False + ) -> _CommandT: ... def announce(self, msg, level: int = 20) -> None: ... def run_commands(self) -> None: ... def run_command(self, command: str) -> None: ... diff --git a/typings/distutils-stubs/sysconfig.pyi b/typings/distutils-stubs/sysconfig.pyi index b75ae74fca..63fade4940 100644 --- a/typings/distutils-stubs/sysconfig.pyi +++ b/typings/distutils-stubs/sysconfig.pyi @@ -1,4 +1,5 @@ from typing import Final, Literal, overload + from typing_extensions import deprecated from setuptools._distutils.ccompiler import CCompiler @@ -7,7 +8,9 @@ PREFIX: Final[str] EXEC_PREFIX: Final[str] @overload -@deprecated("SO is deprecated, use EXT_SUFFIX. Support will be removed when this module is synchronized with stdlib Python 3.11") +@deprecated( + "SO is deprecated, use EXT_SUFFIX. Support will be removed when this module is synchronized with stdlib Python 3.11" +) def get_config_var(name: Literal["SO"]) -> int | str | None: ... @overload def get_config_var(name: str) -> int | str | None: ... @@ -18,5 +21,7 @@ def get_config_vars(arg: str, /, *args: str) -> list[str | int]: ... def get_config_h_filename() -> str: ... def get_makefile_filename() -> str: ... def get_python_inc(plat_specific: bool = False, prefix: str | None = None) -> str: ... -def get_python_lib(plat_specific: bool = False, standard_lib: bool = False, prefix: str | None = None) -> str: ... +def get_python_lib( + plat_specific: bool = False, standard_lib: bool = False, prefix: str | None = None +) -> str: ... def customize_compiler(compiler: CCompiler) -> None: ... diff --git a/typings/distutils-stubs/version.pyi b/typings/distutils-stubs/version.pyi index afb8aa3abe..b0cee01b15 100644 --- a/typings/distutils-stubs/version.pyi +++ b/typings/distutils-stubs/version.pyi @@ -1,5 +1,6 @@ from abc import abstractmethod from re import Pattern + from typing_extensions import Self class Version: