From 38838a7432a34cd7f81a51c3ab221f455b8bf42c Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 16 Mar 2023 16:07:28 -0400 Subject: [PATCH 01/21] fix: fill out more of distutils & setuptools dist Signed-off-by: Henry Schreiner --- stdlib/distutils/dist.pyi | 71 ++++++++++------ .../setuptools/setuptools/_distutils/dist.pyi | 84 ++++++++++++++++++- stubs/setuptools/setuptools/dist.pyi | 39 +++++---- 3 files changed, 150 insertions(+), 44 deletions(-) diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index dfffdc5e11bb..2c75b4044829 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -7,7 +7,7 @@ from typing import IO, Any command_re: Pattern[str] class DistributionMetadata: - def __init__(self, path: FileDescriptorOrPath | None = None) -> None: ... + def __init__(self, path: FileDescriptorOrPath | None = ...) -> None: ... name: str | None version: str | None author: str | None @@ -56,23 +56,23 @@ class DistributionMetadata: class Distribution: cmdclass: dict[str, type[Command]] metadata: DistributionMetadata - def __init__(self, attrs: Mapping[str, Any] | None = None) -> None: ... + def __init__(self, attrs: Mapping[str, Any] | 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: ... + def parse_config_files(self, filenames: Iterable[str] | None = ...) -> None: ... def get_command_obj(self, command: str, create: bool = ...) -> Command | None: ... - global_options: Incomplete + global_options: list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] common_usage: str - display_options: Incomplete - display_option_names: Incomplete - negative_opt: Incomplete + display_options: list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] + display_option_names: list[str] + negative_opt: dict[str, str] verbose: int dry_run: int help: int - command_packages: Incomplete - script_name: Incomplete - script_args: Incomplete - command_options: Incomplete - dist_files: Incomplete + command_packages: list[str] | None + script_name: str | None + script_args: list[str] | None + command_options: dict[str, dict[tuple[str, str]]] | None + dist_files: list[tuple[str, str, str]] packages: Incomplete package_data: Incomplete package_dir: Incomplete @@ -90,7 +90,7 @@ class Distribution: have_run: Incomplete want_user_cfg: bool def dump_option_dicts( - self, header: Incomplete | None = None, commands: Incomplete | None = None, indent: str = "" + self, header: Incomplete | None = ..., commands: Incomplete | None = ..., indent: str = ... ) -> None: ... def find_config_files(self): ... commands: Incomplete @@ -101,16 +101,39 @@ class Distribution: def print_commands(self) -> None: ... def get_command_list(self): ... def get_command_packages(self): ... - def get_command_class(self, command): ... - def reinitialize_command(self, command, reinit_subcommands: int = 0): ... + def get_command_class(self, command: str): ... + def reinitialize_command(self, command: str, reinit_subcommands: int = ...): ... def announce(self, msg, level: int = ...) -> None: ... def run_commands(self) -> None: ... - def run_command(self, command) -> None: ... - def has_pure_modules(self): ... - def has_ext_modules(self): ... - def has_c_libraries(self): ... - def has_modules(self): ... - def has_headers(self): ... - def has_scripts(self): ... - def has_data_files(self): ... - def is_pure(self): ... + 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: ... + + # Autogenerated getters + 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]: ... diff --git a/stubs/setuptools/setuptools/_distutils/dist.pyi b/stubs/setuptools/setuptools/_distutils/dist.pyi index 60365abc6a4a..d50699277792 100644 --- a/stubs/setuptools/setuptools/_distutils/dist.pyi +++ b/stubs/setuptools/setuptools/_distutils/dist.pyi @@ -1,9 +1,12 @@ from _typeshed import FileDescriptorOrPath, Incomplete, SupportsWrite from collections.abc import Iterable, Mapping -from typing import IO +from re import Pattern +from typing import IO, Any from .cmd import Command +command_re: Pattern[str] + class DistributionMetadata: def __init__(self, path: FileDescriptorOrPath | None = ...) -> None: ... name: str | None @@ -54,7 +57,84 @@ class DistributionMetadata: class Distribution: cmdclass: dict[str, type[Command]] metadata: DistributionMetadata - def __init__(self, attrs: Mapping[str, Incomplete] | None = ...) -> None: ... + def __init__(self, attrs: Mapping[str, Any] | None = ...) -> None: ... def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ... def parse_config_files(self, filenames: Iterable[str] | None = ...) -> None: ... def get_command_obj(self, command: str, create: bool = ...) -> Command | None: ... + global_options: list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] + common_usage: str + display_options: list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] + display_option_names: list[str] + negative_opt: dict[str, str] + verbose: int + dry_run: int + help: int + command_packages: list[str] | None + script_name: str | None + script_args: list[str] | None + command_options: dict[str, dict[tuple[str, str]]] | None + dist_files: list[tuple[str, str, str]] + packages: Incomplete + package_data: Incomplete + 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 = ..., commands: Incomplete | 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): ... + def get_command_class(self, command: str): ... + def reinitialize_command(self, command: str, reinit_subcommands: int = ...): ... + def announce(self, msg, level: int = ...) -> 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: ... + + # Autogenerated getters + 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]: ... diff --git a/stubs/setuptools/setuptools/dist.pyi b/stubs/setuptools/setuptools/dist.pyi index 0cd758671b96..d6c73dd7a266 100644 --- a/stubs/setuptools/setuptools/dist.pyi +++ b/stubs/setuptools/setuptools/dist.pyi @@ -1,36 +1,39 @@ from _typeshed import Incomplete +from collections.abc import Generator, Iterable, Mapping +from typing import Any from setuptools import SetuptoolsDeprecationWarning from ._distutils.dist import Distribution as _Distribution class Distribution(_Distribution): - def patch_missing_pkg_info(self, attrs) -> None: ... - package_data: Incomplete - dist_files: Incomplete - src_root: Incomplete - dependency_links: Incomplete - setup_requires: Incomplete - def __init__(self, attrs: Incomplete | None = ...) -> None: ... - def warn_dash_deprecation(self, opt, section): ... - def make_option_lowercase(self, opt, section): ... - def parse_config_files(self, filenames: Incomplete | None = ..., ignore_option_errors: bool = ...) -> None: ... - def fetch_build_eggs(self, requires): ... - def finalize_options(self): ... - def get_egg_cache_dir(self): ... + def patch_missing_pkg_info(self, attrs: Mapping[str, Any]) -> None: ... + package_data: dict[str, list[str]] + dist_files: list[str] + src_root: str | None + dependency_links: list[str] + setup_requires: list[str] + def __init__(self, attrs: dict[str, Any] | None = ...) -> None: ... + def warn_dash_deprecation(self, opt: str, section: str) -> str: ... + def make_option_lowercase(self, opt: str, section: str) -> str: ... + def parse_config_files(self, filenames: Iterable[str] | None = ..., ignore_option_errors: bool = ...) -> None: ... + def fetch_build_eggs(self, requires: str | Iterable[str]): ... + def finalize_options(self) -> None: ... + def get_egg_cache_dir(self) -> str: ... def fetch_build_egg(self, req): ... - def get_command_class(self, command): ... + def get_command_class(self, command: str): ... def print_commands(self): ... def get_command_list(self): ... def include(self, **attrs) -> None: ... packages: Incomplete py_modules: Incomplete ext_modules: Incomplete - def exclude_package(self, package) -> None: ... - def has_contents_for(self, package): ... + def exclude_package(self, package: str) -> None: ... + def has_contents_for(self, package: str) -> bool | None: ... def exclude(self, **attrs) -> None: ... - def get_cmdline_options(self): ... - def iter_distribution_names(self) -> None: ... + def get_cmdline_options(self) -> dict[str, dict[str, str | None]]: ... + def iter_distribution_names(self) -> Generator[str, None, None]: ... def handle_display_options(self, option_order): ... + def run_command(self, command: str) -> None: ... class DistDeprecationWarning(SetuptoolsDeprecationWarning): ... From 3feff342e41b34050468f0968dfcfa24e082138d Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 16 Mar 2023 16:21:56 -0400 Subject: [PATCH 02/21] fix: typo in dict Signed-off-by: Henry Schreiner --- stdlib/distutils/dist.pyi | 2 +- stubs/setuptools/setuptools/_distutils/dist.pyi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index 2c75b4044829..4d11665c20ce 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -71,7 +71,7 @@ class Distribution: command_packages: list[str] | None script_name: str | None script_args: list[str] | None - command_options: dict[str, dict[tuple[str, str]]] | None + command_options: dict[str, dict[str, tuple[str, str]]] | None dist_files: list[tuple[str, str, str]] packages: Incomplete package_data: Incomplete diff --git a/stubs/setuptools/setuptools/_distutils/dist.pyi b/stubs/setuptools/setuptools/_distutils/dist.pyi index d50699277792..76b64ceac894 100644 --- a/stubs/setuptools/setuptools/_distutils/dist.pyi +++ b/stubs/setuptools/setuptools/_distutils/dist.pyi @@ -72,7 +72,7 @@ class Distribution: command_packages: list[str] | None script_name: str | None script_args: list[str] | None - command_options: dict[str, dict[tuple[str, str]]] | None + command_options: dict[str, dict[str, tuple[str, str]]] | None dist_files: list[tuple[str, str, str]] packages: Incomplete package_data: Incomplete From 0d6dac4a5fa0f7b886bf71184214e553b098192a Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 16 Mar 2023 16:39:56 -0400 Subject: [PATCH 03/21] fix: remove some duplication in Distribution subclass Signed-off-by: Henry Schreiner --- stubs/setuptools/setuptools/_distutils/dist.pyi | 2 +- stubs/setuptools/setuptools/dist.pyi | 8 -------- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/stubs/setuptools/setuptools/_distutils/dist.pyi b/stubs/setuptools/setuptools/_distutils/dist.pyi index 76b64ceac894..c72b0087ede1 100644 --- a/stubs/setuptools/setuptools/_distutils/dist.pyi +++ b/stubs/setuptools/setuptools/_distutils/dist.pyi @@ -75,7 +75,7 @@ class Distribution: command_options: dict[str, dict[str, tuple[str, str]]] | None dist_files: list[tuple[str, str, str]] packages: Incomplete - package_data: Incomplete + package_data: dict[str, list[str]] package_dir: Incomplete py_modules: Incomplete libraries: Incomplete diff --git a/stubs/setuptools/setuptools/dist.pyi b/stubs/setuptools/setuptools/dist.pyi index d6c73dd7a266..8f21344e0996 100644 --- a/stubs/setuptools/setuptools/dist.pyi +++ b/stubs/setuptools/setuptools/dist.pyi @@ -8,8 +8,6 @@ from ._distutils.dist import Distribution as _Distribution class Distribution(_Distribution): def patch_missing_pkg_info(self, attrs: Mapping[str, Any]) -> None: ... - package_data: dict[str, list[str]] - dist_files: list[str] src_root: str | None dependency_links: list[str] setup_requires: list[str] @@ -18,16 +16,10 @@ class Distribution(_Distribution): def make_option_lowercase(self, opt: str, section: str) -> str: ... def parse_config_files(self, filenames: Iterable[str] | None = ..., ignore_option_errors: bool = ...) -> None: ... def fetch_build_eggs(self, requires: str | Iterable[str]): ... - def finalize_options(self) -> None: ... def get_egg_cache_dir(self) -> str: ... def fetch_build_egg(self, req): ... def get_command_class(self, command: str): ... - def print_commands(self): ... - def get_command_list(self): ... def include(self, **attrs) -> None: ... - packages: Incomplete - py_modules: Incomplete - ext_modules: Incomplete def exclude_package(self, package: str) -> None: ... def has_contents_for(self, package: str) -> bool | None: ... def exclude(self, **attrs) -> None: ... From 89169c2cedab328c205364c0ddf8c20f7292f869 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 16 Mar 2023 20:42:49 +0000 Subject: [PATCH 04/21] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/setuptools/setuptools/dist.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/setuptools/setuptools/dist.pyi b/stubs/setuptools/setuptools/dist.pyi index 8f21344e0996..d67ea97bf263 100644 --- a/stubs/setuptools/setuptools/dist.pyi +++ b/stubs/setuptools/setuptools/dist.pyi @@ -1,4 +1,3 @@ -from _typeshed import Incomplete from collections.abc import Generator, Iterable, Mapping from typing import Any From b9a24db93c4f3cb0b11441b9f02bcfec34c91636 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 16 Mar 2023 16:49:46 -0400 Subject: [PATCH 05/21] revert: pull out generate method addition Signed-off-by: Henry Schreiner --- stdlib/distutils/dist.pyi | 23 ------------------- .../setuptools/setuptools/_distutils/dist.pyi | 23 ------------------- 2 files changed, 46 deletions(-) diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index 4d11665c20ce..378b5715969c 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -114,26 +114,3 @@ class Distribution: def has_scripts(self) -> bool: ... def has_data_files(self) -> bool: ... def is_pure(self) -> bool: ... - - # Autogenerated getters - 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]: ... diff --git a/stubs/setuptools/setuptools/_distutils/dist.pyi b/stubs/setuptools/setuptools/_distutils/dist.pyi index c72b0087ede1..7770690ae5c2 100644 --- a/stubs/setuptools/setuptools/_distutils/dist.pyi +++ b/stubs/setuptools/setuptools/_distutils/dist.pyi @@ -115,26 +115,3 @@ class Distribution: def has_scripts(self) -> bool: ... def has_data_files(self) -> bool: ... def is_pure(self) -> bool: ... - - # Autogenerated getters - 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]: ... From 36e43a6cc856549940aa2f8f1d8f003cb21984a5 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 16 Mar 2023 17:12:45 -0400 Subject: [PATCH 06/21] revert: use default values when possible Signed-off-by: Henry Schreiner --- stdlib/distutils/dist.pyi | 10 +++++----- stubs/setuptools/setuptools/_distutils/dist.pyi | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index 378b5715969c..69e5d5899149 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -7,7 +7,7 @@ from typing import IO, Any command_re: Pattern[str] class DistributionMetadata: - def __init__(self, path: FileDescriptorOrPath | None = ...) -> None: ... + def __init__(self, path: FileDescriptorOrPath | None = None) -> None: ... name: str | None version: str | None author: str | None @@ -56,10 +56,10 @@ class DistributionMetadata: class Distribution: cmdclass: dict[str, type[Command]] metadata: DistributionMetadata - def __init__(self, attrs: Mapping[str, Any] | None = ...) -> None: ... + def __init__(self, attrs: Mapping[str, Any] | 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: ... - def get_command_obj(self, command: str, create: bool = ...) -> Command | None: ... + def get_command_obj(self, command: str, create: bool = None) -> Command | None: ... global_options: list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] common_usage: str display_options: list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] @@ -90,7 +90,7 @@ class Distribution: have_run: Incomplete want_user_cfg: bool def dump_option_dicts( - self, header: Incomplete | None = ..., commands: Incomplete | None = ..., indent: str = ... + self, header: Incomplete | None = None, commands: Incomplete | None = None, indent: str = "" ) -> None: ... def find_config_files(self): ... commands: Incomplete @@ -102,7 +102,7 @@ class Distribution: def get_command_list(self): ... def get_command_packages(self): ... def get_command_class(self, command: str): ... - def reinitialize_command(self, command: str, reinit_subcommands: int = ...): ... + def reinitialize_command(self, command: str, reinit_subcommands: int = 0): ... def announce(self, msg, level: int = ...) -> None: ... def run_commands(self) -> None: ... def run_command(self, command: str) -> None: ... diff --git a/stubs/setuptools/setuptools/_distutils/dist.pyi b/stubs/setuptools/setuptools/_distutils/dist.pyi index 7770690ae5c2..aee6d7109f3e 100644 --- a/stubs/setuptools/setuptools/_distutils/dist.pyi +++ b/stubs/setuptools/setuptools/_distutils/dist.pyi @@ -8,7 +8,7 @@ from .cmd import Command command_re: Pattern[str] class DistributionMetadata: - def __init__(self, path: FileDescriptorOrPath | None = ...) -> None: ... + def __init__(self, path: FileDescriptorOrPath | None = None) -> None: ... name: str | None version: str | None author: str | None @@ -57,10 +57,10 @@ class DistributionMetadata: class Distribution: cmdclass: dict[str, type[Command]] metadata: DistributionMetadata - def __init__(self, attrs: Mapping[str, Any] | None = ...) -> None: ... + def __init__(self, attrs: Mapping[str, Any] | 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: ... - def get_command_obj(self, command: str, create: bool = ...) -> Command | None: ... + def get_command_obj(self, command: str, create: bool = None) -> Command | None: ... global_options: list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] common_usage: str display_options: list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] @@ -91,7 +91,7 @@ class Distribution: have_run: Incomplete want_user_cfg: bool def dump_option_dicts( - self, header: Incomplete | None = ..., commands: Incomplete | None = ..., indent: str = ... + self, header: Incomplete | None = None, commands: Incomplete | None = None, indent: str = "" ) -> None: ... def find_config_files(self): ... commands: Incomplete @@ -103,7 +103,7 @@ class Distribution: def get_command_list(self): ... def get_command_packages(self): ... def get_command_class(self, command: str): ... - def reinitialize_command(self, command: str, reinit_subcommands: int = ...): ... + def reinitialize_command(self, command: str, reinit_subcommands: int = 0): ... def announce(self, msg, level: int = ...) -> None: ... def run_commands(self) -> None: ... def run_command(self, command: str) -> None: ... From 3edf7bdf4f7accc742988b52abd37555f51e4874 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 16 Mar 2023 17:18:52 -0400 Subject: [PATCH 07/21] Apply suggestions from code review Co-authored-by: Alex Waygood --- stdlib/distutils/dist.pyi | 4 ++-- stubs/setuptools/setuptools/_distutils/dist.pyi | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index 69e5d5899149..8815c56235dd 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -58,8 +58,8 @@ class Distribution: metadata: DistributionMetadata def __init__(self, attrs: Mapping[str, Any] | 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: ... - def get_command_obj(self, command: str, create: bool = None) -> Command | None: ... + def parse_config_files(self, filenames: Iterable[str] | None = None) -> None: ... + def get_command_obj(self, command: str, create: bool = True) -> Command | None: ... global_options: list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] common_usage: str display_options: list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] diff --git a/stubs/setuptools/setuptools/_distutils/dist.pyi b/stubs/setuptools/setuptools/_distutils/dist.pyi index aee6d7109f3e..48e5404375ea 100644 --- a/stubs/setuptools/setuptools/_distutils/dist.pyi +++ b/stubs/setuptools/setuptools/_distutils/dist.pyi @@ -59,8 +59,8 @@ class Distribution: metadata: DistributionMetadata def __init__(self, attrs: Mapping[str, Any] | 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: ... - def get_command_obj(self, command: str, create: bool = None) -> Command | None: ... + def parse_config_files(self, filenames: Iterable[str] | None = None) -> None: ... + def get_command_obj(self, command: str, create: bool = True) -> Command | None: ... global_options: list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] common_usage: str display_options: list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] From dae9ea66af579adf82285ba91a5b804d963a07e1 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 16 Mar 2023 18:18:49 -0400 Subject: [PATCH 08/21] tests: ignore true/1 in stubgen Signed-off-by: Henry Schreiner --- stubs/setuptools/@tests/stubtest_allowlist.txt | 2 ++ tests/stubtest_allowlists/py3_common.txt | 1 + 2 files changed, 3 insertions(+) diff --git a/stubs/setuptools/@tests/stubtest_allowlist.txt b/stubs/setuptools/@tests/stubtest_allowlist.txt index 30bb58115fec..fabaa83a8859 100644 --- a/stubs/setuptools/@tests/stubtest_allowlist.txt +++ b/stubs/setuptools/@tests/stubtest_allowlist.txt @@ -27,6 +27,8 @@ pkg_resources.to_filename pkg_resources.PathMetadata.egg_info pkg_resources.EggMetadata.loader +setuptools._distutils.dist.Distribution.get_command_obj # 1 used for True + # Uncomment once ignore_missing_stub is turned off # # Not supported by typeshed # setuptools.py34compat diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 0a19ad75615c..a31d366b3498 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -85,6 +85,7 @@ ctypes.memset # CFunctionType ctypes.string_at # docstring argument name is wrong ctypes.wstring_at # docstring argument name is wrong distutils.command.bdist_packager # It exists in docs as package name but not in code except as a mention in a comment. +distutils.dist.Distribution.get_command_obj # 1 used for True distutils.version.Version._cmp # class should have declared this distutils.version.Version.parse # class should have declared this enum.Enum._generate_next_value_ From 9b10a9453694685cbb9b8656d06a74bf85f6e5f1 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 16 Mar 2023 20:26:58 -0400 Subject: [PATCH 09/21] tests: fix location Signed-off-by: Henry Schreiner --- tests/stubtest_allowlists/py3_common.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index a31d366b3498..38ab591ee18e 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -84,8 +84,8 @@ ctypes.memmove # CFunctionType ctypes.memset # CFunctionType ctypes.string_at # docstring argument name is wrong ctypes.wstring_at # docstring argument name is wrong +distutils.core.Distribution.get_command_obj # 1 used for True distutils.command.bdist_packager # It exists in docs as package name but not in code except as a mention in a comment. -distutils.dist.Distribution.get_command_obj # 1 used for True distutils.version.Version._cmp # class should have declared this distutils.version.Version.parse # class should have declared this enum.Enum._generate_next_value_ From 6e8901490abfb7e148cf716fa30949556108dc29 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Thu, 16 Mar 2023 20:57:41 -0400 Subject: [PATCH 10/21] tests: fix location (2x) Signed-off-by: Henry Schreiner --- tests/stubtest_allowlists/py3_common.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 38ab591ee18e..fe7cb459f7ef 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -86,6 +86,7 @@ ctypes.string_at # docstring argument name is wrong ctypes.wstring_at # docstring argument name is wrong distutils.core.Distribution.get_command_obj # 1 used for True distutils.command.bdist_packager # It exists in docs as package name but not in code except as a mention in a comment. +distutils.dist.Distribution.get_command_obj # 1 used for True distutils.version.Version._cmp # class should have declared this distutils.version.Version.parse # class should have declared this enum.Enum._generate_next_value_ From 6a6874bc8343efbfd32352928da45b5ca4ec5650 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 17 Mar 2023 09:52:07 -0400 Subject: [PATCH 11/21] fix: address review feedback Signed-off-by: Henry Schreiner --- stdlib/distutils/dist.pyi | 24 ++++++++++--------- .../setuptools/setuptools/_distutils/dist.pyi | 22 +++++++++-------- stubs/setuptools/setuptools/dist.pyi | 5 ++-- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index 1d803fb60a85..d6ae7b431252 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -2,10 +2,12 @@ from _typeshed import FileDescriptorOrPath, Incomplete, SupportsWrite from collections.abc import Iterable, Mapping from distutils.cmd import Command from re import Pattern -from typing import IO, Any +from typing import IO, Any, ClassVar command_re: Pattern[str] +_OptionsList = list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] + class DistributionMetadata: def __init__(self, path: FileDescriptorOrPath | None = None) -> None: ... name: str | None @@ -60,21 +62,21 @@ class Distribution: def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ... def parse_config_files(self, filenames: Iterable[str] | None = None) -> None: ... def get_command_obj(self, command: str, create: bool = True) -> Command | None: ... - global_options: list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] - common_usage: str - display_options: list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] - display_option_names: list[str] - negative_opt: dict[str, str] + 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: int dry_run: int help: int command_packages: list[str] | None script_name: str | None script_args: list[str] | None - command_options: dict[str, dict[str, tuple[str, str]]] | None + command_options: dict[str, dict[str, tuple[str, str]]] dist_files: list[tuple[str, str, str]] packages: Incomplete - package_data: Incomplete + package_data: dict[str, list[str]] package_dir: Incomplete py_modules: Incomplete libraries: Incomplete @@ -101,11 +103,11 @@ class Distribution: def print_commands(self) -> None: ... def get_command_list(self): ... def get_command_packages(self): ... - def get_command_class(self, command: str): ... - def reinitialize_command(self, command: str, reinit_subcommands: int = 0): ... + def get_command_class(self, command: str | Command) -> type[Command]: ... + def reinitialize_command(self, command: str | Command, reinit_subcommands: int = 0) -> Command: ... def announce(self, msg, level: int = ...) -> None: ... def run_commands(self) -> None: ... - def run_command(self, command: str) -> None: ... + def run_command(self, command: str | Command) -> None: ... def has_pure_modules(self) -> bool: ... def has_ext_modules(self) -> bool: ... def has_c_libraries(self) -> bool: ... diff --git a/stubs/setuptools/setuptools/_distutils/dist.pyi b/stubs/setuptools/setuptools/_distutils/dist.pyi index 16bb61c03593..010a9c098986 100644 --- a/stubs/setuptools/setuptools/_distutils/dist.pyi +++ b/stubs/setuptools/setuptools/_distutils/dist.pyi @@ -1,12 +1,14 @@ from _typeshed import FileDescriptorOrPath, Incomplete, SupportsWrite from collections.abc import Iterable, Mapping from re import Pattern -from typing import IO, Any +from typing import IO, Any, ClassVar from .cmd import Command command_re: Pattern[str] +_OptionsList = list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] + class DistributionMetadata: def __init__(self, path: FileDescriptorOrPath | None = None) -> None: ... name: str | None @@ -61,18 +63,18 @@ class Distribution: def get_option_dict(self, command: str) -> dict[str, tuple[str, str]]: ... def parse_config_files(self, filenames: Iterable[str] | None = None) -> None: ... def get_command_obj(self, command: str, create: bool = True) -> Command | None: ... - global_options: list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] - common_usage: str - display_options: list[tuple[str, str | None, str, int] | tuple[str, str | None, str]] - display_option_names: list[str] - negative_opt: dict[str, str] + 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: int dry_run: int help: int command_packages: list[str] | None script_name: str | None script_args: list[str] | None - command_options: dict[str, dict[str, tuple[str, 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]] @@ -102,11 +104,11 @@ class Distribution: def print_commands(self) -> None: ... def get_command_list(self): ... def get_command_packages(self): ... - def get_command_class(self, command: str): ... - def reinitialize_command(self, command: str, reinit_subcommands: int = 0): ... + def get_command_class(self, command: str | Command) -> type[Command]: ... + def reinitialize_command(self, command: str | Command, reinit_subcommands: int = 0) -> Command: ... def announce(self, msg, level: int = ...) -> None: ... def run_commands(self) -> None: ... - def run_command(self, command: str) -> None: ... + def run_command(self, command: str | Command) -> None: ... def has_pure_modules(self) -> bool: ... def has_ext_modules(self) -> bool: ... def has_c_libraries(self) -> bool: ... diff --git a/stubs/setuptools/setuptools/dist.pyi b/stubs/setuptools/setuptools/dist.pyi index d67ea97bf263..49288755193d 100644 --- a/stubs/setuptools/setuptools/dist.pyi +++ b/stubs/setuptools/setuptools/dist.pyi @@ -2,6 +2,7 @@ from collections.abc import Generator, Iterable, Mapping from typing import Any from setuptools import SetuptoolsDeprecationWarning +from setuptools import Command from ._distutils.dist import Distribution as _Distribution @@ -17,7 +18,7 @@ class Distribution(_Distribution): def fetch_build_eggs(self, requires: str | Iterable[str]): ... def get_egg_cache_dir(self) -> str: ... def fetch_build_egg(self, req): ... - def get_command_class(self, command: str): ... + def get_command_class(self, command: str | Command) -> type[Command]: ... def include(self, **attrs) -> None: ... def exclude_package(self, package: str) -> None: ... def has_contents_for(self, package: str) -> bool | None: ... @@ -25,6 +26,6 @@ class Distribution(_Distribution): def get_cmdline_options(self) -> dict[str, dict[str, str | None]]: ... def iter_distribution_names(self) -> Generator[str, None, None]: ... def handle_display_options(self, option_order): ... - def run_command(self, command: str) -> None: ... + def run_command(self, command: str | Commmand) -> None: ... class DistDeprecationWarning(SetuptoolsDeprecationWarning): ... From 2997bfb8c5014e5c0fcaa345378bb7cf9702f619 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Mar 2023 13:54:17 +0000 Subject: [PATCH 12/21] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/setuptools/setuptools/dist.pyi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stubs/setuptools/setuptools/dist.pyi b/stubs/setuptools/setuptools/dist.pyi index 49288755193d..860ce3158c7a 100644 --- a/stubs/setuptools/setuptools/dist.pyi +++ b/stubs/setuptools/setuptools/dist.pyi @@ -1,8 +1,7 @@ from collections.abc import Generator, Iterable, Mapping from typing import Any -from setuptools import SetuptoolsDeprecationWarning -from setuptools import Command +from setuptools import Command, SetuptoolsDeprecationWarning from ._distutils.dist import Distribution as _Distribution From e0cfd777253f4202b3d37c6d984ab319b2ba0d61 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 17 Mar 2023 10:19:20 -0400 Subject: [PATCH 13/21] Apply suggestions from code review Co-authored-by: Jelle Zijlstra --- stubs/setuptools/setuptools/_distutils/dist.pyi | 2 +- stubs/setuptools/setuptools/dist.pyi | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/stubs/setuptools/setuptools/_distutils/dist.pyi b/stubs/setuptools/setuptools/_distutils/dist.pyi index 010a9c098986..87f6c52c50be 100644 --- a/stubs/setuptools/setuptools/_distutils/dist.pyi +++ b/stubs/setuptools/setuptools/_distutils/dist.pyi @@ -104,7 +104,7 @@ class Distribution: def print_commands(self) -> None: ... def get_command_list(self): ... def get_command_packages(self): ... - def get_command_class(self, command: str | Command) -> type[Command]: ... + def get_command_class(self, command: str) -> type[Command]: ... def reinitialize_command(self, command: str | Command, reinit_subcommands: int = 0) -> Command: ... def announce(self, msg, level: int = ...) -> None: ... def run_commands(self) -> None: ... diff --git a/stubs/setuptools/setuptools/dist.pyi b/stubs/setuptools/setuptools/dist.pyi index 860ce3158c7a..7dd18ccfc510 100644 --- a/stubs/setuptools/setuptools/dist.pyi +++ b/stubs/setuptools/setuptools/dist.pyi @@ -17,7 +17,7 @@ class Distribution(_Distribution): def fetch_build_eggs(self, requires: str | Iterable[str]): ... def get_egg_cache_dir(self) -> str: ... def fetch_build_egg(self, req): ... - def get_command_class(self, command: str | Command) -> type[Command]: ... + def get_command_class(self, command: str) -> type[Command]: ... def include(self, **attrs) -> None: ... def exclude_package(self, package: str) -> None: ... def has_contents_for(self, package: str) -> bool | None: ... @@ -25,6 +25,6 @@ class Distribution(_Distribution): def get_cmdline_options(self) -> dict[str, dict[str, str | None]]: ... def iter_distribution_names(self) -> Generator[str, None, None]: ... def handle_display_options(self, option_order): ... - def run_command(self, command: str | Commmand) -> None: ... + def run_command(self, command: str | Command) -> None: ... class DistDeprecationWarning(SetuptoolsDeprecationWarning): ... From 50d9bf43635e334cae1bc89ff884151250c81474 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 17 Mar 2023 10:19:56 -0400 Subject: [PATCH 14/21] Apply suggestions from code review Co-authored-by: Jelle Zijlstra --- stdlib/distutils/dist.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index d6ae7b431252..ef548b9eece3 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -103,7 +103,7 @@ class Distribution: def print_commands(self) -> None: ... def get_command_list(self): ... def get_command_packages(self): ... - def get_command_class(self, command: str | Command) -> type[Command]: ... + def get_command_class(self, command: str) -> type[Command]: ... def reinitialize_command(self, command: str | Command, reinit_subcommands: int = 0) -> Command: ... def announce(self, msg, level: int = ...) -> None: ... def run_commands(self) -> None: ... From 8cae27df605db478d1ddb208948f79a5beb44717 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 17 Mar 2023 11:03:49 -0400 Subject: [PATCH 15/21] fix: run_command in supertype Signed-off-by: Henry Schreiner --- stubs/setuptools/setuptools/dist.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stubs/setuptools/setuptools/dist.pyi b/stubs/setuptools/setuptools/dist.pyi index 7dd18ccfc510..04b232c34779 100644 --- a/stubs/setuptools/setuptools/dist.pyi +++ b/stubs/setuptools/setuptools/dist.pyi @@ -25,6 +25,5 @@ class Distribution(_Distribution): def get_cmdline_options(self) -> dict[str, dict[str, str | None]]: ... def iter_distribution_names(self) -> Generator[str, None, None]: ... def handle_display_options(self, option_order): ... - def run_command(self, command: str | Command) -> None: ... class DistDeprecationWarning(SetuptoolsDeprecationWarning): ... From 1053c94ef86798dff61b6e4d27bc4262918cd7f1 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 17 Mar 2023 11:09:49 -0400 Subject: [PATCH 16/21] refactor: use overload for reinit command Signed-off-by: Henry Schreiner refactor: use overload for reinit command Signed-off-by: Henry Schreiner --- stdlib/distutils/dist.pyi | 11 ++++++++--- stubs/setuptools/setuptools/_distutils/dist.pyi | 11 ++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index ef548b9eece3..6e240386a0f1 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -2,11 +2,13 @@ from _typeshed import FileDescriptorOrPath, Incomplete, SupportsWrite from collections.abc import Iterable, Mapping from distutils.cmd import Command from re import Pattern -from typing import IO, Any, ClassVar +from typing import IO, Any, ClassVar, TypeVar, overload +from typing_extensions import TypeAlias command_re: Pattern[str] -_OptionsList = 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: def __init__(self, path: FileDescriptorOrPath | None = None) -> None: ... @@ -104,7 +106,10 @@ class Distribution: def get_command_list(self): ... def get_command_packages(self): ... def get_command_class(self, command: str) -> type[Command]: ... - def reinitialize_command(self, command: str | Command, reinit_subcommands: int = 0) -> Command: ... + @overload + def reinitialize_command(self, command: str, reinit_subcommands: int = 0) -> Command: ... + @overload + def reinitialize_command(self, command: _CommandT, reinit_subcommands: int = 0) -> _CommandT: ... def announce(self, msg, level: int = ...) -> None: ... def run_commands(self) -> None: ... def run_command(self, command: str | Command) -> None: ... diff --git a/stubs/setuptools/setuptools/_distutils/dist.pyi b/stubs/setuptools/setuptools/_distutils/dist.pyi index 87f6c52c50be..ff307d2d1f86 100644 --- a/stubs/setuptools/setuptools/_distutils/dist.pyi +++ b/stubs/setuptools/setuptools/_distutils/dist.pyi @@ -1,13 +1,15 @@ from _typeshed import FileDescriptorOrPath, Incomplete, SupportsWrite from collections.abc import Iterable, Mapping from re import Pattern -from typing import IO, Any, ClassVar +from typing import IO, Any, ClassVar, TypeVar, overload +from typing_extensions import TypeAlias from .cmd import Command command_re: Pattern[str] -_OptionsList = 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: def __init__(self, path: FileDescriptorOrPath | None = None) -> None: ... @@ -105,7 +107,10 @@ class Distribution: def get_command_list(self): ... def get_command_packages(self): ... def get_command_class(self, command: str) -> type[Command]: ... - def reinitialize_command(self, command: str | Command, reinit_subcommands: int = 0) -> Command: ... + @overload + def reinitialize_command(self, command: str, reinit_subcommands: int = 0) -> Command: ... + @overload + def reinitialize_command(self, command: _CommandT, reinit_subcommands: int = 0) -> _CommandT: ... def announce(self, msg, level: int = ...) -> None: ... def run_commands(self) -> None: ... def run_command(self, command: str | Command) -> None: ... From 109cbe57480ced44d324c1393aa1f31b96dfaeb1 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 17 Mar 2023 14:25:56 -0400 Subject: [PATCH 17/21] Apply suggestions from code review Co-authored-by: Alex Waygood --- stdlib/distutils/dist.pyi | 6 +++--- stubs/setuptools/setuptools/_distutils/dist.pyi | 6 +++--- stubs/setuptools/setuptools/dist.pyi | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index 6e240386a0f1..697bd896ff4d 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -107,12 +107,12 @@ class Distribution: def get_command_packages(self): ... def get_command_class(self, command: str) -> type[Command]: ... @overload - def reinitialize_command(self, command: str, reinit_subcommands: int = 0) -> Command: ... + def reinitialize_command(self, command: str, reinit_subcommands: bool = False) -> Command: ... @overload - def reinitialize_command(self, command: _CommandT, reinit_subcommands: int = 0) -> _CommandT: ... + def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool = False) -> _CommandT: ... def announce(self, msg, level: int = ...) -> None: ... def run_commands(self) -> None: ... - def run_command(self, command: str | Command) -> 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: ... diff --git a/stubs/setuptools/setuptools/_distutils/dist.pyi b/stubs/setuptools/setuptools/_distutils/dist.pyi index ff307d2d1f86..25cdceb00d84 100644 --- a/stubs/setuptools/setuptools/_distutils/dist.pyi +++ b/stubs/setuptools/setuptools/_distutils/dist.pyi @@ -91,8 +91,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 = "" @@ -113,7 +113,7 @@ class Distribution: def reinitialize_command(self, command: _CommandT, reinit_subcommands: int = 0) -> _CommandT: ... def announce(self, msg, level: int = ...) -> None: ... def run_commands(self) -> None: ... - def run_command(self, command: str | Command) -> 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: ... diff --git a/stubs/setuptools/setuptools/dist.pyi b/stubs/setuptools/setuptools/dist.pyi index 04b232c34779..10f8461ca115 100644 --- a/stubs/setuptools/setuptools/dist.pyi +++ b/stubs/setuptools/setuptools/dist.pyi @@ -10,7 +10,7 @@ class Distribution(_Distribution): src_root: str | None dependency_links: list[str] setup_requires: list[str] - def __init__(self, attrs: dict[str, Any] | None = ...) -> None: ... + def __init__(self, attrs: MutableMapping[str, Any] | None = None) -> None: ... def warn_dash_deprecation(self, opt: str, section: str) -> str: ... def make_option_lowercase(self, opt: str, section: str) -> str: ... def parse_config_files(self, filenames: Iterable[str] | None = ..., ignore_option_errors: bool = ...) -> None: ... @@ -23,7 +23,7 @@ class Distribution(_Distribution): def has_contents_for(self, package: str) -> bool | None: ... def exclude(self, **attrs) -> None: ... def get_cmdline_options(self) -> dict[str, dict[str, str | None]]: ... - def iter_distribution_names(self) -> Generator[str, None, None]: ... + def iter_distribution_names(self) -> Iterator[str]: ... def handle_display_options(self, option_order): ... class DistDeprecationWarning(SetuptoolsDeprecationWarning): ... From 7d2034baa7477b955560f2d02634c8b8f1b41c67 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 17 Mar 2023 14:26:09 -0400 Subject: [PATCH 18/21] Apply suggestions from code review Co-authored-by: Alex Waygood --- stubs/setuptools/setuptools/_distutils/dist.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/setuptools/setuptools/_distutils/dist.pyi b/stubs/setuptools/setuptools/_distutils/dist.pyi index 25cdceb00d84..cfa6c6ea148c 100644 --- a/stubs/setuptools/setuptools/_distutils/dist.pyi +++ b/stubs/setuptools/setuptools/_distutils/dist.pyi @@ -108,9 +108,9 @@ class Distribution: def get_command_packages(self): ... def get_command_class(self, command: str) -> type[Command]: ... @overload - def reinitialize_command(self, command: str, reinit_subcommands: int = 0) -> Command: ... + def reinitialize_command(self, command: str, reinit_subcommands: bool = False) -> Command: ... @overload - def reinitialize_command(self, command: _CommandT, reinit_subcommands: int = 0) -> _CommandT: ... + def reinitialize_command(self, command: _CommandT, reinit_subcommands: bool = False) -> _CommandT: ... def announce(self, msg, level: int = ...) -> None: ... def run_commands(self) -> None: ... def run_command(self, command: str) -> None: ... From 4eed3c6da7f8ea78049e09cecade8fd94c8becc5 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Mar 2023 18:27:07 +0000 Subject: [PATCH 19/21] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/setuptools/setuptools/dist.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/setuptools/setuptools/dist.pyi b/stubs/setuptools/setuptools/dist.pyi index 10f8461ca115..6cda58f10b3e 100644 --- a/stubs/setuptools/setuptools/dist.pyi +++ b/stubs/setuptools/setuptools/dist.pyi @@ -1,4 +1,4 @@ -from collections.abc import Generator, Iterable, Mapping +from collections.abc import Iterable, Mapping from typing import Any from setuptools import Command, SetuptoolsDeprecationWarning From 9db1265913fb56fe8d4b0ba8248e1d794c2659d4 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 17 Mar 2023 14:35:22 -0400 Subject: [PATCH 20/21] fix: missing imports Signed-off-by: Henry Schreiner --- stubs/setuptools/setuptools/dist.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/setuptools/setuptools/dist.pyi b/stubs/setuptools/setuptools/dist.pyi index 6cda58f10b3e..e67935297bc7 100644 --- a/stubs/setuptools/setuptools/dist.pyi +++ b/stubs/setuptools/setuptools/dist.pyi @@ -1,4 +1,4 @@ -from collections.abc import Iterable, Mapping +from collections.abc import Iterable, Mapping, MutableMapping, Iterator from typing import Any from setuptools import Command, SetuptoolsDeprecationWarning From b29448ee0c73ec22bb672cda77a231863d74108e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 17 Mar 2023 18:36:40 +0000 Subject: [PATCH 21/21] [pre-commit.ci] auto fixes from pre-commit.com hooks --- stubs/setuptools/setuptools/dist.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/setuptools/setuptools/dist.pyi b/stubs/setuptools/setuptools/dist.pyi index e67935297bc7..3e34d9b1b6f9 100644 --- a/stubs/setuptools/setuptools/dist.pyi +++ b/stubs/setuptools/setuptools/dist.pyi @@ -1,4 +1,4 @@ -from collections.abc import Iterable, Mapping, MutableMapping, Iterator +from collections.abc import Iterable, Iterator, Mapping, MutableMapping from typing import Any from setuptools import Command, SetuptoolsDeprecationWarning