From c99adf4b8564e16148f287faf0e5081ed560cc8b Mon Sep 17 00:00:00 2001 From: Avasam Date: Fri, 17 May 2024 02:33:18 -0400 Subject: [PATCH] `distutils`: improve boolean parameters with int defaults (#11928) --- stdlib/distutils/archive_util.pyi | 12 +++-- stdlib/distutils/ccompiler.pyi | 38 +++++++++------ stdlib/distutils/cmd.pyi | 36 ++++++++------ stdlib/distutils/command/bdist_msi.pyi | 8 ++-- stdlib/distutils/command/build_py.pyi | 4 +- stdlib/distutils/command/check.pyi | 4 +- stdlib/distutils/command/config.pyi | 6 +-- stdlib/distutils/core.pyi | 4 +- stdlib/distutils/dir_util.pyi | 22 +++++---- stdlib/distutils/file_util.pyi | 13 ++--- stdlib/distutils/filelist.pyi | 14 ++++-- stdlib/distutils/spawn.pyi | 6 ++- stdlib/distutils/sysconfig.pyi | 6 ++- stdlib/distutils/text_file.pyi | 14 +++--- stdlib/distutils/util.pyi | 12 +++-- stubs/setuptools/setuptools/__init__.pyi | 6 ++- .../setuptools/_distutils/archive_util.pyi | 12 +++-- .../setuptools/_distutils/ccompiler.pyi | 38 +++++++++------ .../setuptools/setuptools/_distutils/cmd.pyi | 48 +++++++++---------- .../_distutils/command/build_py.pyi | 3 +- .../setuptools/_distutils/filelist.pyi | 20 +++++--- .../setuptools/_distutils/sysconfig.pyi | 6 ++- .../setuptools/setuptools/_distutils/util.pyi | 12 +++-- .../setuptools/command/bdist_egg.pyi | 10 +++- .../setuptools/command/build_ext.pyi | 4 +- .../setuptools/command/install_lib.pyi | 11 ++++- 26 files changed, 228 insertions(+), 141 deletions(-) diff --git a/stdlib/distutils/archive_util.pyi b/stdlib/distutils/archive_util.pyi index a8947ce35..d8a844f7e 100644 --- a/stdlib/distutils/archive_util.pyi +++ b/stdlib/distutils/archive_util.pyi @@ -1,10 +1,12 @@ +from typing import Literal + def make_archive( base_name: str, format: str, root_dir: str | None = None, base_dir: str | None = None, - verbose: int = 0, - dry_run: int = 0, + verbose: bool | Literal[0, 1] = 0, + dry_run: bool | Literal[0, 1] = 0, owner: str | None = None, group: str | None = None, ) -> str: ... @@ -12,9 +14,9 @@ def make_tarball( base_name: str, base_dir: str, compress: str | None = "gzip", - verbose: int = 0, - dry_run: int = 0, + 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: int = 0, dry_run: int = 0) -> 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/stdlib/distutils/ccompiler.pyi b/stdlib/distutils/ccompiler.pyi index cc097728f..abb9fbaa3 100644 --- a/stdlib/distutils/ccompiler.pyi +++ b/stdlib/distutils/ccompiler.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable -from typing import Any +from typing import Any, Literal from typing_extensions import TypeAlias _Macro: TypeAlias = tuple[str] | tuple[str, str | None] @@ -10,7 +10,11 @@ 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: int = 0, dry_run: int = 0, force: int = 0 + 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: ... @@ -25,7 +29,9 @@ class CCompiler: library_dirs: list[str] runtime_library_dirs: list[str] objects: list[str] - def __init__(self, verbose: int = 0, dry_run: int = 0, force: int = 0) -> None: ... + 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: ... @@ -39,7 +45,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 = ...) -> 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, @@ -58,7 +64,7 @@ class CCompiler: output_dir: str | None = None, macros: list[_Macro] | None = None, include_dirs: list[str] | None = None, - debug: bool = ..., + debug: bool | Literal[0, 1] = 0, extra_preargs: list[str] | None = None, extra_postargs: list[str] | None = None, depends: list[str] | None = None, @@ -68,7 +74,7 @@ class CCompiler: objects: list[str], output_libname: str, output_dir: str | None = None, - debug: bool = ..., + debug: bool | Literal[0, 1] = 0, target_lang: str | None = None, ) -> None: ... def link( @@ -81,7 +87,7 @@ class CCompiler: library_dirs: list[str] | None = None, runtime_library_dirs: list[str] | None = None, export_symbols: list[str] | None = None, - debug: bool = ..., + debug: bool | Literal[0, 1] = 0, extra_preargs: list[str] | None = None, extra_postargs: list[str] | None = None, build_temp: str | None = None, @@ -95,7 +101,7 @@ class CCompiler: libraries: list[str] | None = None, library_dirs: list[str] | None = None, runtime_library_dirs: list[str] | None = None, - debug: bool = ..., + debug: bool | Literal[0, 1] = 0, extra_preargs: list[str] | None = None, extra_postargs: list[str] | None = None, target_lang: str | None = None, @@ -109,7 +115,7 @@ class CCompiler: library_dirs: list[str] | None = None, runtime_library_dirs: list[str] | None = None, export_symbols: list[str] | None = None, - debug: bool = ..., + debug: bool | Literal[0, 1] = 0, extra_preargs: list[str] | None = None, extra_postargs: list[str] | None = None, build_temp: str | None = None, @@ -124,7 +130,7 @@ class CCompiler: library_dirs: list[str] | None = None, runtime_library_dirs: list[str] | None = None, export_symbols: list[str] | None = None, - debug: bool = ..., + debug: bool | Literal[0, 1] = 0, extra_preargs: list[str] | None = None, extra_postargs: list[str] | None = None, build_temp: str | None = None, @@ -139,10 +145,14 @@ class CCompiler: extra_preargs: list[str] | None = None, extra_postargs: list[str] | None = None, ) -> None: ... - def executable_filename(self, basename: str, strip_dir: int = 0, output_dir: str = "") -> str: ... - def library_filename(self, libname: str, lib_type: str = "static", strip_dir: int = 0, output_dir: str = "") -> str: ... - def object_filenames(self, source_filenames: list[str], strip_dir: int = 0, output_dir: str = "") -> list[str]: ... - def shared_object_filename(self, basename: str, strip_dir: int = 0, output_dir: str = "") -> str: ... + def executable_filename(self, basename: str, strip_dir: bool | Literal[0, 1] = 0, output_dir: str = "") -> str: ... + def library_filename( + self, libname: str, lib_type: str = "static", strip_dir: bool | Literal[0, 1] = 0, output_dir: str = "" + ) -> str: ... + def object_filenames( + self, source_filenames: list[str], strip_dir: bool | Literal[0, 1] = 0, output_dir: str = "" + ) -> list[str]: ... + def shared_object_filename(self, basename: str, strip_dir: bool | Literal[0, 1] = 0, output_dir: str = "") -> str: ... def execute(self, func: Callable[..., object], args: tuple[Any, ...], 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/stdlib/distutils/cmd.pyi b/stdlib/distutils/cmd.pyi index 61fce37b8..94838ce2c 100644 --- a/stdlib/distutils/cmd.pyi +++ b/stdlib/distutils/cmd.pyi @@ -1,8 +1,8 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, Unused from abc import abstractmethod from collections.abc import Callable, Iterable from distutils.dist import Distribution -from typing import Any +from typing import Any, Literal class Command: distribution: Distribution @@ -22,27 +22,33 @@ class Command: 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 get_finalized_command(self, command: str, create: int = 1) -> Command: ... - def reinitialize_command(self, command: Command | str, reinit_subcommands: int = 0) -> Command: ... + def get_finalized_command(self, command: str, create: bool | Literal[0, 1] = 1) -> Command: ... + def reinitialize_command(self, command: Command | str, reinit_subcommands: bool | Literal[0, 1] = 0) -> Command: ... 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[..., object], args: Iterable[Any], msg: str | None = None, level: int = 1) -> None: ... def mkpath(self, name: str, mode: int = 0o777) -> None: ... def copy_file( - self, infile: str, outfile: str, preserve_mode: int = 1, preserve_times: int = 1, link: str | None = None, level: Any = 1 - ) -> tuple[str, bool]: ... # level is not used + self, + infile: str, + outfile: str, + preserve_mode: bool | Literal[0, 1] = 1, + preserve_times: bool | Literal[0, 1] = 1, + link: str | None = None, + level: Unused = 1, + ) -> tuple[str, bool]: ... def copy_tree( self, infile: str, outfile: str, - preserve_mode: int = 1, - preserve_times: int = 1, - preserve_symlinks: int = 0, - level: Any = 1, - ) -> list[str]: ... # level is not used - def move_file(self, src: str, dst: str, level: Any = 1) -> str: ... # level is not used - def spawn(self, cmd: Iterable[str], search_path: int = 1, level: Any = 1) -> None: ... # level is not used + 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]: ... + def move_file(self, src: str, dst: str, level: Unused = 1) -> str: ... + def spawn(self, cmd: Iterable[str], search_path: bool | Literal[0, 1] = 1, level: Unused = 1) -> None: ... def make_archive( self, base_name: str, @@ -60,7 +66,7 @@ class Command: args: list[Any], exec_msg: str | None = None, skip_msg: str | None = None, - level: Any = 1, - ) -> None: ... # level is not used + level: Unused = 1, + ) -> None: ... def ensure_finalized(self) -> None: ... def dump_options(self, header: Incomplete | None = None, indent: str = "") -> None: ... diff --git a/stdlib/distutils/command/bdist_msi.pyi b/stdlib/distutils/command/bdist_msi.pyi index fa98e86d5..d1eb374ff 100644 --- a/stdlib/distutils/command/bdist_msi.pyi +++ b/stdlib/distutils/command/bdist_msi.pyi @@ -1,5 +1,5 @@ import sys -from typing import Any +from typing import Any, Literal from ..cmd import Command @@ -9,9 +9,9 @@ if sys.platform == "win32": class PyDialog(Dialog): def __init__(self, *args, **kw) -> None: ... def title(self, title) -> None: ... - def back(self, title, next, name: str = "Back", active: int = 1): ... - def cancel(self, title, next, name: str = "Cancel", active: int = 1): ... - def next(self, title, next, name: str = "Next", active: int = 1): ... + 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): diff --git a/stdlib/distutils/command/build_py.pyi b/stdlib/distutils/command/build_py.pyi index ca4e4ed7e..4c607c6da 100644 --- a/stdlib/distutils/command/build_py.pyi +++ b/stdlib/distutils/command/build_py.pyi @@ -1,4 +1,4 @@ -from typing import Any +from typing import Any, Literal from ..cmd import Command from ..util import Mixin2to3 as Mixin2to3 @@ -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: int = 1): ... + 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: ... diff --git a/stdlib/distutils/command/check.pyi b/stdlib/distutils/command/check.pyi index 9cbcc6c87..da041d825 100644 --- a/stdlib/distutils/command/check.pyi +++ b/stdlib/distutils/command/check.pyi @@ -1,4 +1,4 @@ -from typing import Any +from typing import Any, Literal from typing_extensions import TypeAlias from ..cmd import Command @@ -16,7 +16,7 @@ class SilentReporter(_Reporter): report_level, halt_level, stream: Any | None = ..., - debug: int = ..., + debug: bool | Literal[0, 1] = 0, encoding: str = ..., error_handler: str = ..., ) -> None: ... diff --git a/stdlib/distutils/command/config.pyi b/stdlib/distutils/command/config.pyi index 7077c9a4c..5d1aa22de 100644 --- a/stdlib/distutils/command/config.pyi +++ b/stdlib/distutils/command/config.pyi @@ -1,6 +1,6 @@ from collections.abc import Sequence from re import Pattern -from typing import Any +from typing import Any, Literal from ..ccompiler import CCompiler from ..cmd import Command @@ -65,8 +65,8 @@ class config(Command): include_dirs: Sequence[str] | None = None, libraries: Sequence[str] | None = None, library_dirs: Sequence[str] | None = None, - decl: int = 0, - call: int = 0, + decl: bool | Literal[0, 1] = 0, + call: bool | Literal[0, 1] = 0, ) -> bool: ... def check_lib( self, diff --git a/stdlib/distutils/core.pyi b/stdlib/distutils/core.pyi index c41c8ba19..f3c434df0 100644 --- a/stdlib/distutils/core.pyi +++ b/stdlib/distutils/core.pyi @@ -3,7 +3,7 @@ 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 +from typing import Any, Literal USAGE: str @@ -45,7 +45,7 @@ def setup( command_packages: list[str] = ..., command_options: Mapping[str, Mapping[str, tuple[Any, Any]]] = ..., package_data: Mapping[str, list[str]] = ..., - include_package_data: bool = ..., + include_package_data: bool | Literal[0, 1] = ..., libraries: list[str] = ..., headers: list[str] = ..., ext_package: str = ..., diff --git a/stdlib/distutils/dir_util.pyi b/stdlib/distutils/dir_util.pyi index 2324a2d50..65c8051cc 100644 --- a/stdlib/distutils/dir_util.pyi +++ b/stdlib/distutils/dir_util.pyi @@ -1,13 +1,17 @@ -def mkpath(name: str, mode: int = 0o777, verbose: int = 1, dry_run: int = 0) -> list[str]: ... -def create_tree(base_dir: str, files: list[str], mode: int = 0o777, verbose: int = 1, dry_run: int = 0) -> None: ... +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: str, files: list[str], mode: int = 0o777, verbose: bool | Literal[0, 1] = 1, dry_run: bool | Literal[0, 1] = 0 +) -> None: ... def copy_tree( src: str, dst: str, - preserve_mode: int = 1, - preserve_times: int = 1, - preserve_symlinks: int = 0, - update: int = 0, - verbose: int = 1, - dry_run: int = 0, + 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: str, verbose: int = 1, dry_run: int = 0) -> None: ... +def remove_tree(directory: str, verbose: bool | Literal[0, 1] = 1, dry_run: bool | Literal[0, 1] = 0) -> None: ... diff --git a/stdlib/distutils/file_util.pyi b/stdlib/distutils/file_util.pyi index a97dfca60..3c2c45bcd 100644 --- a/stdlib/distutils/file_util.pyi +++ b/stdlib/distutils/file_util.pyi @@ -1,14 +1,15 @@ from collections.abc import Sequence +from typing import Literal def copy_file( src: str, dst: str, - preserve_mode: bool = ..., - preserve_times: bool = ..., - update: bool = ..., + 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 = ..., - dry_run: bool = ..., + verbose: bool | Literal[0, 1] = 1, + dry_run: bool | Literal[0, 1] = 0, ) -> tuple[str, str]: ... -def move_file(src: str, dst: str, verbose: bool = ..., dry_run: bool = ...) -> str: ... +def move_file(src: str, dst: str, verbose: bool | Literal[0, 1] = 0, dry_run: bool | Literal[0, 1] = 0) -> str: ... def write_file(filename: str, contents: Sequence[str]) -> None: ... diff --git a/stdlib/distutils/filelist.pyi b/stdlib/distutils/filelist.pyi index 25db2f3cb..607a78a1f 100644 --- a/stdlib/distutils/filelist.pyi +++ b/stdlib/distutils/filelist.pyi @@ -23,7 +23,11 @@ class FileList: 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: int = 0 + 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( @@ -33,7 +37,11 @@ class FileList: 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: int = 0 + 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]: ... @@ -46,5 +54,5 @@ def translate_pattern( 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: int = 0 + 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/stdlib/distutils/spawn.pyi b/stdlib/distutils/spawn.pyi index a8a2c4140..50d89aeb9 100644 --- a/stdlib/distutils/spawn.pyi +++ b/stdlib/distutils/spawn.pyi @@ -1,2 +1,6 @@ -def spawn(cmd: list[str], search_path: bool = ..., verbose: bool = ..., dry_run: bool = ...) -> None: ... +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/stdlib/distutils/sysconfig.pyi b/stdlib/distutils/sysconfig.pyi index e2399a6cf..da72e3275 100644 --- a/stdlib/distutils/sysconfig.pyi +++ b/stdlib/distutils/sysconfig.pyi @@ -23,8 +23,10 @@ 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 = ..., prefix: str | None = None) -> str: ... -def get_python_lib(plat_specific: bool = ..., standard_lib: bool = ..., prefix: str | None = None) -> 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): diff --git a/stdlib/distutils/text_file.pyi b/stdlib/distutils/text_file.pyi index 4a6cf1db7..54951af7e 100644 --- a/stdlib/distutils/text_file.pyi +++ b/stdlib/distutils/text_file.pyi @@ -1,4 +1,4 @@ -from typing import IO +from typing import IO, Literal class TextFile: def __init__( @@ -6,12 +6,12 @@ class TextFile: filename: str | None = None, file: IO[str] | None = None, *, - strip_comments: bool = ..., - lstrip_ws: bool = ..., - rstrip_ws: bool = ..., - skip_blanks: bool = ..., - join_lines: bool = ..., - collapse_join: bool = ..., + 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: ... diff --git a/stdlib/distutils/util.pyi b/stdlib/distutils/util.pyi index 835266edd..3e1fa064f 100644 --- a/stdlib/distutils/util.pyi +++ b/stdlib/distutils/util.pyi @@ -10,17 +10,21 @@ 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[..., object], args: tuple[Any, ...], msg: str | None = None, verbose: bool = ..., dry_run: bool = ... + func: Callable[..., object], + args: tuple[Any, ...], + 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 = ..., + force: bool | Literal[0, 1] = 0, prefix: str | None = None, base_dir: str | None = None, - verbose: bool = ..., - dry_run: bool = ..., + verbose: bool | Literal[0, 1] = 1, + dry_run: bool | Literal[0, 1] = 0, direct: bool | None = None, ) -> None: ... def rfc822_escape(header: str) -> str: ... diff --git a/stubs/setuptools/setuptools/__init__.pyi b/stubs/setuptools/setuptools/__init__.pyi index 23263e9b7..75dbef9ba 100644 --- a/stubs/setuptools/setuptools/__init__.pyi +++ b/stubs/setuptools/setuptools/__init__.pyi @@ -1,7 +1,7 @@ from _typeshed import StrPath from abc import abstractmethod from collections.abc import Iterable, Mapping, Sequence -from typing import Any +from typing import Any, Literal from ._distutils.cmd import Command as _Command from .depends import Require as Require @@ -76,7 +76,9 @@ class Command(_Command): distribution: Distribution def __init__(self, dist: Distribution, **kw: Any) -> None: ... def ensure_string_list(self, option: str | list[str]) -> None: ... - def reinitialize_command(self, command: _Command | str, reinit_subcommands: int = 0, **kw: Any) -> _Command: ... + def reinitialize_command( + self, command: _Command | str, reinit_subcommands: bool | Literal[0, 1] = 0, **kw: Any + ) -> _Command: ... @abstractmethod def initialize_options(self) -> None: ... @abstractmethod diff --git a/stubs/setuptools/setuptools/_distutils/archive_util.pyi b/stubs/setuptools/setuptools/_distutils/archive_util.pyi index 38458fc0e..d871af20b 100644 --- a/stubs/setuptools/setuptools/_distutils/archive_util.pyi +++ b/stubs/setuptools/setuptools/_distutils/archive_util.pyi @@ -1,10 +1,12 @@ +from typing import Literal + def make_archive( base_name: str, format: str, root_dir: str | None = ..., base_dir: str | None = ..., - verbose: int = ..., - dry_run: int = ..., + verbose: bool | Literal[0, 1] = 0, + dry_run: bool | Literal[0, 1] = 0, owner: str | None = ..., group: str | None = ..., ) -> str: ... @@ -12,9 +14,9 @@ def make_tarball( base_name: str, base_dir: str, compress: str | None = ..., - verbose: int = ..., - dry_run: int = ..., + verbose: bool | Literal[0, 1] = 0, + dry_run: bool | Literal[0, 1] = 0, owner: str | None = ..., group: str | None = ..., ) -> str: ... -def make_zipfile(base_name: str, base_dir: str, verbose: int = ..., dry_run: int = ...) -> 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/stubs/setuptools/setuptools/_distutils/ccompiler.pyi b/stubs/setuptools/setuptools/_distutils/ccompiler.pyi index 5d439131b..911933030 100644 --- a/stubs/setuptools/setuptools/_distutils/ccompiler.pyi +++ b/stubs/setuptools/setuptools/_distutils/ccompiler.pyi @@ -1,5 +1,5 @@ from collections.abc import Callable -from typing import Any, ClassVar +from typing import Any, ClassVar, Literal from typing_extensions import TypeAlias _Macro: TypeAlias = tuple[str] | tuple[str, str | None] @@ -10,7 +10,11 @@ def gen_lib_options( def gen_preprocess_options(macros: list[_Macro], include_dirs: list[str]) -> list[str]: ... def get_default_compiler(osname: str | None = ..., platform: str | None = ...) -> str: ... def new_compiler( - plat: str | None = ..., compiler: str | None = ..., verbose: int = ..., dry_run: int = ..., force: int = ... + plat: str | None = ..., + compiler: str | 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: ... @@ -34,7 +38,9 @@ class CCompiler: library_dirs: list[str] runtime_library_dirs: list[str] objects: list[str] - def __init__(self, verbose: int = ..., dry_run: int = ..., force: int = ...) -> None: ... + 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: ... @@ -48,7 +54,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 = ...) -> 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, @@ -67,7 +73,7 @@ class CCompiler: output_dir: str | None = ..., macros: list[_Macro] | None = ..., include_dirs: list[str] | None = ..., - debug: bool = ..., + debug: bool | Literal[0, 1] = 0, extra_preargs: list[str] | None = ..., extra_postargs: list[str] | None = ..., depends: list[str] | None = ..., @@ -77,7 +83,7 @@ class CCompiler: objects: list[str], output_libname: str, output_dir: str | None = ..., - debug: bool = ..., + debug: bool | Literal[0, 1] = 0, target_lang: str | None = ..., ) -> None: ... def link( @@ -90,7 +96,7 @@ class CCompiler: library_dirs: list[str] | None = ..., runtime_library_dirs: list[str] | None = ..., export_symbols: list[str] | None = ..., - debug: bool = ..., + debug: bool | Literal[0, 1] = 0, extra_preargs: list[str] | None = ..., extra_postargs: list[str] | None = ..., build_temp: str | None = ..., @@ -104,7 +110,7 @@ class CCompiler: libraries: list[str] | None = ..., library_dirs: list[str] | None = ..., runtime_library_dirs: list[str] | None = ..., - debug: bool = ..., + debug: bool | Literal[0, 1] = 0, extra_preargs: list[str] | None = ..., extra_postargs: list[str] | None = ..., target_lang: str | None = ..., @@ -118,7 +124,7 @@ class CCompiler: library_dirs: list[str] | None = ..., runtime_library_dirs: list[str] | None = ..., export_symbols: list[str] | None = ..., - debug: bool = ..., + debug: bool | Literal[0, 1] = 0, extra_preargs: list[str] | None = ..., extra_postargs: list[str] | None = ..., build_temp: str | None = ..., @@ -133,7 +139,7 @@ class CCompiler: library_dirs: list[str] | None = ..., runtime_library_dirs: list[str] | None = ..., export_symbols: list[str] | None = ..., - debug: bool = ..., + debug: bool | Literal[0, 1] = 0, extra_preargs: list[str] | None = ..., extra_postargs: list[str] | None = ..., build_temp: str | None = ..., @@ -148,10 +154,14 @@ class CCompiler: extra_preargs: list[str] | None = ..., extra_postargs: list[str] | None = ..., ) -> None: ... - def executable_filename(self, basename: str, strip_dir: int = ..., output_dir: str = ...) -> str: ... - def library_filename(self, libname: str, lib_type: str = "static", strip_dir: int = 0, output_dir: str = "") -> str: ... - def object_filenames(self, source_filenames: list[str], strip_dir: int = ..., output_dir: str = ...) -> list[str]: ... - def shared_object_filename(self, basename: str, strip_dir: int = ..., output_dir: str = ...) -> str: ... + def executable_filename(self, basename: str, strip_dir: bool | Literal[0, 1] = 0, output_dir: str = ...) -> str: ... + def library_filename( + self, libname: str, lib_type: str = "static", strip_dir: bool | Literal[0, 1] = 0, output_dir: str = "" + ) -> str: ... + def object_filenames( + self, source_filenames: list[str], strip_dir: bool | Literal[0, 1] = 0, output_dir: str = ... + ) -> list[str]: ... + def shared_object_filename(self, basename: str, strip_dir: bool | Literal[0, 1] = 0, output_dir: str = ...) -> str: ... def execute(self, func: Callable[..., object], args: tuple[Any, ...], msg: str | None = ..., level: int = ...) -> None: ... def spawn(self, cmd: list[str]) -> None: ... def mkpath(self, name: str, mode: int = ...) -> None: ... diff --git a/stubs/setuptools/setuptools/_distutils/cmd.pyi b/stubs/setuptools/setuptools/_distutils/cmd.pyi index 7a4f6fc7b..f67086103 100644 --- a/stubs/setuptools/setuptools/_distutils/cmd.pyi +++ b/stubs/setuptools/setuptools/_distutils/cmd.pyi @@ -1,7 +1,7 @@ -from _typeshed import Incomplete +from _typeshed import Incomplete, Unused from abc import abstractmethod from collections.abc import Callable, Iterable -from typing import ClassVar +from typing import ClassVar, Literal from typing_extensions import Self from .dist import Distribution @@ -25,8 +25,8 @@ class Command: 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 get_finalized_command(self, command: str, create: int = ...) -> Command: ... - def reinitialize_command(self, command: Command | str, reinit_subcommands: int = ...) -> Command: ... + def get_finalized_command(self, command: str, create: bool | Literal[0, 1] = 1) -> Command: ... + def reinitialize_command(self, command: Command | str, reinit_subcommands: bool | Literal[0, 1] = 0) -> Command: ... def run_command(self, command: str) -> None: ... def get_sub_commands(self) -> list[str]: ... def warn(self, msg: str) -> None: ... @@ -38,30 +38,30 @@ class Command: self, infile: str, outfile: str, - preserve_mode: int = ..., - preserve_times: int = ..., - link: str | None = ..., - level: int = ..., - ) -> tuple[str, bool]: ... # level is not used + preserve_mode: bool | Literal[0, 1] = 1, + preserve_times: bool | Literal[0, 1] = 1, + link: str | None = None, + level: Unused = 1, + ) -> tuple[str, bool]: ... def copy_tree( self, infile: str, outfile: str, - preserve_mode: int = ..., - preserve_times: int = ..., - preserve_symlinks: int = ..., - level: int = ..., - ) -> list[str]: ... # level is not used - def move_file(self, src: str, dst: str, level: int = ...) -> str: ... # level is not used - def spawn(self, cmd: Iterable[str], search_path: int = ..., level: int = ...) -> None: ... # level is not used + 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]: ... + def move_file(self, src: str, dst: str, level: Unused = 1) -> str: ... + def spawn(self, cmd: Iterable[str], search_path: bool | Literal[0, 1] = 1, level: Unused = 1) -> None: ... def make_archive( self, base_name: str, format: str, - root_dir: str | None = ..., - base_dir: str | None = ..., - owner: str | None = ..., - group: str | None = ..., + root_dir: str | None = None, + base_dir: str | None = None, + owner: str | None = None, + group: str | None = None, ) -> str: ... def make_file( self, @@ -69,7 +69,7 @@ class Command: outfile: str, func: Callable[..., object], args: list[Incomplete], - exec_msg: str | None = ..., - skip_msg: str | None = ..., - level: int = ..., - ) -> None: ... # level is not used + exec_msg: str | None = None, + skip_msg: str | None = None, + level: Unused = 1, + ) -> None: ... diff --git a/stubs/setuptools/setuptools/_distutils/command/build_py.pyi b/stubs/setuptools/setuptools/_distutils/command/build_py.pyi index b5bada633..d40c00e6c 100644 --- a/stubs/setuptools/setuptools/_distutils/command/build_py.pyi +++ b/stubs/setuptools/setuptools/_distutils/command/build_py.pyi @@ -1,4 +1,5 @@ from _typeshed import Incomplete +from typing import Literal from ..cmd import Command @@ -31,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: int = ...): ... + 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: ... diff --git a/stubs/setuptools/setuptools/_distutils/filelist.pyi b/stubs/setuptools/setuptools/_distutils/filelist.pyi index f46703d6d..a20a471ff 100644 --- a/stubs/setuptools/setuptools/_distutils/filelist.pyi +++ b/stubs/setuptools/setuptools/_distutils/filelist.pyi @@ -17,21 +17,29 @@ class FileList: def process_template_line(self, line: str) -> None: ... @overload def include_pattern( - self, pattern: str, anchor: bool | Literal[0, 1] = ..., prefix: str | None = ..., is_regex: Literal[0, False] = ... + self, pattern: str, anchor: bool | Literal[0, 1] = 1, prefix: str | None = ..., is_regex: Literal[0, False] = 0 ) -> 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 | Literal[0, 1] = ..., prefix: str | None = ..., is_regex: int = ... + self, + pattern: str | Pattern[str], + anchor: bool | Literal[0, 1] = 1, + prefix: str | None = ..., + is_regex: bool | Literal[0, 1] = 0, ) -> bool: ... @overload def exclude_pattern( - self, pattern: str, anchor: bool | Literal[0, 1] = ..., prefix: str | None = ..., is_regex: Literal[0, False] = ... + self, pattern: str, anchor: bool | Literal[0, 1] = 1, prefix: str | None = ..., is_regex: Literal[0, False] = 0 ) -> 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 | Literal[0, 1] = ..., prefix: str | None = ..., is_regex: int = ... + self, + pattern: str | Pattern[str], + anchor: bool | Literal[0, 1] = 1, + prefix: str | None = ..., + is_regex: bool | Literal[0, 1] = 0, ) -> bool: ... diff --git a/stubs/setuptools/setuptools/_distutils/sysconfig.pyi b/stubs/setuptools/setuptools/_distutils/sysconfig.pyi index edcc64426..4a90dc202 100644 --- a/stubs/setuptools/setuptools/_distutils/sysconfig.pyi +++ b/stubs/setuptools/setuptools/_distutils/sysconfig.pyi @@ -17,6 +17,8 @@ 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 = ..., prefix: str | None = ...) -> str: ... -def get_python_lib(plat_specific: bool = ..., standard_lib: bool = ..., prefix: str | None = ...) -> str: ... +def get_python_inc(plat_specific: bool | Literal[0, 1] = 0, prefix: str | None = ...) -> str: ... +def get_python_lib( + plat_specific: bool | Literal[0, 1] = 0, standard_lib: bool | Literal[0, 1] = 0, prefix: str | None = ... +) -> str: ... def customize_compiler(compiler: CCompiler) -> None: ... diff --git a/stubs/setuptools/setuptools/_distutils/util.pyi b/stubs/setuptools/setuptools/_distutils/util.pyi index 690571438..0896bf77b 100644 --- a/stubs/setuptools/setuptools/_distutils/util.pyi +++ b/stubs/setuptools/setuptools/_distutils/util.pyi @@ -13,17 +13,21 @@ def subst_vars(s: str, local_vars: Mapping[str, str]) -> None: ... def grok_environment_error(exc: object, prefix: str = ...) -> str: ... def split_quoted(s: str) -> list[str]: ... def execute( - func: Callable[..., object], args: tuple[Any, ...], msg: str | None = ..., verbose: bool = ..., dry_run: bool = ... + func: Callable[..., object], + args: tuple[Any, ...], + msg: str | 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 = ..., - force: bool = ..., + force: bool | Literal[0, 1] = 0, prefix: str | None = ..., base_dir: str | None = ..., - verbose: bool = ..., - dry_run: bool = ..., + verbose: bool | Literal[0, 1] = 1, + dry_run: bool | Literal[0, 1] = 0, direct: bool | None = ..., ) -> None: ... def rfc822_escape(header: str) -> str: ... diff --git a/stubs/setuptools/setuptools/command/bdist_egg.pyi b/stubs/setuptools/setuptools/command/bdist_egg.pyi index 2b6276bbe..aec617755 100644 --- a/stubs/setuptools/setuptools/command/bdist_egg.pyi +++ b/stubs/setuptools/setuptools/command/bdist_egg.pyi @@ -1,5 +1,6 @@ from _typeshed import Incomplete from collections.abc import Generator +from typing import Literal from .. import Command @@ -46,4 +47,11 @@ def can_scan(): ... INSTALL_DIRECTORY_ATTRS: Incomplete -def make_zipfile(zip_filename, base_dir, verbose: int = 0, dry_run: int = 0, compress: bool = True, mode: str = "w"): ... +def make_zipfile( + zip_filename, + base_dir, + verbose: bool | Literal[0, 1] = 0, + dry_run: bool | Literal[0, 1] = 0, + compress: bool = True, + mode: str = "w", +): ... diff --git a/stubs/setuptools/setuptools/command/build_ext.pyi b/stubs/setuptools/setuptools/command/build_ext.pyi index 21973fb79..70f9c6c8f 100644 --- a/stubs/setuptools/setuptools/command/build_ext.pyi +++ b/stubs/setuptools/setuptools/command/build_ext.pyi @@ -1,5 +1,5 @@ from _typeshed import Incomplete -from typing import Any, ClassVar +from typing import Any, ClassVar, Literal from .._distutils.command.build_ext import build_ext as _build_ext @@ -40,7 +40,7 @@ def link_shared_object( library_dirs: Incomplete | None = None, runtime_library_dirs: Incomplete | None = None, export_symbols: Incomplete | None = None, - debug: int = 0, + debug: bool | Literal[0, 1] = 0, extra_preargs: Incomplete | None = None, extra_postargs: Incomplete | None = None, build_temp: Incomplete | None = None, diff --git a/stubs/setuptools/setuptools/command/install_lib.pyi b/stubs/setuptools/setuptools/command/install_lib.pyi index f76028e0f..4428816b1 100644 --- a/stubs/setuptools/setuptools/command/install_lib.pyi +++ b/stubs/setuptools/setuptools/command/install_lib.pyi @@ -1,9 +1,18 @@ +from _typeshed import Unused +from typing import Literal + from .._distutils.command import install_lib as orig class install_lib(orig.install_lib): def run(self) -> None: ... def get_exclusions(self): ... def copy_tree( - self, infile, outfile, preserve_mode: int = 1, preserve_times: int = 1, preserve_symlinks: int = 0, level: int = 1 + self, + infile, + outfile, + preserve_mode: bool | Literal[0, 1] = 1, + preserve_times: bool | Literal[0, 1] = 1, + preserve_symlinks: bool | Literal[0, 1] = 0, + level: Unused = 1, ): ... def get_outputs(self): ...