distutils: improve boolean parameters with int defaults (#11928)

This commit is contained in:
Avasam
2024-05-17 02:33:18 -04:00
committed by GitHub
parent 240114ac1a
commit c99adf4b85
26 changed files with 228 additions and 141 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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