distutils: Type execute using TypeVarTuple (#12405)

This commit is contained in:
Avasam
2024-07-23 08:16:14 -04:00
committed by GitHub
parent ce9f32db8d
commit ef42f3b765
6 changed files with 43 additions and 19 deletions

View File

@@ -1,10 +1,11 @@
from _typeshed import BytesPath, StrPath
from _typeshed import BytesPath, StrPath, Unused
from collections.abc import Callable, Iterable
from distutils.file_util import _BytesPathT, _StrPathT
from typing import Any, Literal, overload
from typing_extensions import TypeAlias
from typing import Literal, overload
from typing_extensions import TypeAlias, TypeVarTuple, Unpack
_Macro: TypeAlias = tuple[str] | tuple[str, str | None]
_Ts = TypeVarTuple("_Ts")
def gen_lib_options(
compiler: CCompiler, library_dirs: list[str], runtime_library_dirs: list[str], libraries: list[str]
@@ -161,7 +162,9 @@ class CCompiler:
def shared_object_filename(self, basename: str, strip_dir: Literal[0, False] = 0, output_dir: StrPath = "") -> str: ...
@overload
def shared_object_filename(self, basename: StrPath, strip_dir: Literal[1, True], output_dir: StrPath = "") -> str: ...
def execute(self, func: Callable[..., object], args: tuple[Any, ...], msg: str | None = None, level: int = 1) -> None: ...
def execute(
self, func: Callable[[Unpack[_Ts]], Unused], args: tuple[Unpack[_Ts]], msg: str | None = None, level: int = 1
) -> None: ...
def spawn(self, cmd: list[str]) -> None: ...
def mkpath(self, name: str, mode: int = 0o777) -> None: ...
@overload

View File

@@ -4,6 +4,9 @@ from collections.abc import Callable, Iterable
from distutils.dist import Distribution
from distutils.file_util import _BytesPathT, _StrPathT
from typing import Any, ClassVar, Literal, overload
from typing_extensions import TypeVarTuple, Unpack
_Ts = TypeVarTuple("_Ts")
class Command:
distribution: Distribution
@@ -29,7 +32,9 @@ class 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 execute(
self, func: Callable[[Unpack[_Ts]], Unused], args: tuple[Unpack[_Ts]], msg: str | None = None, level: int = 1
) -> None: ...
def mkpath(self, name: str, mode: int = 0o777) -> None: ...
@overload
def copy_file(
@@ -89,8 +94,8 @@ class Command:
self,
infiles: str | list[str] | tuple[str, ...],
outfile: StrOrBytesPath,
func: Callable[..., object],
args: list[Any],
func: Callable[[Unpack[_Ts]], Unused],
args: tuple[Unpack[_Ts]],
exec_msg: str | None = None,
skip_msg: str | None = None,
level: Unused = 1,

View File

@@ -1,6 +1,9 @@
from _typeshed import StrPath, Unused
from collections.abc import Callable, Container, Iterable, Mapping
from typing import Any, Literal
from typing_extensions import TypeVarTuple, Unpack
_Ts = TypeVarTuple("_Ts")
def get_host_platform() -> str: ...
def get_platform() -> str: ...
@@ -10,8 +13,8 @@ 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, ...],
func: Callable[[Unpack[_Ts]], Unused],
args: tuple[Unpack[_Ts]],
msg: str | None = None,
verbose: bool | Literal[0, 1] = 0,
dry_run: bool | Literal[0, 1] = 0,

View File

@@ -1,11 +1,12 @@
from _typeshed import BytesPath, StrPath
from _typeshed import BytesPath, StrPath, Unused
from collections.abc import Callable, Iterable
from typing import Any, ClassVar, Literal, TypeVar, overload
from typing_extensions import TypeAlias
from typing import ClassVar, Literal, TypeVar, overload
from typing_extensions import TypeAlias, TypeVarTuple, Unpack
_Macro: TypeAlias = tuple[str] | tuple[str, str | None]
_StrPathT = TypeVar("_StrPathT", bound=StrPath)
_BytesPathT = TypeVar("_BytesPathT", bound=BytesPath)
_Ts = TypeVarTuple("_Ts")
def gen_lib_options(
compiler: CCompiler, library_dirs: list[str], runtime_library_dirs: list[str], libraries: list[str]
@@ -165,7 +166,9 @@ class CCompiler:
def shared_object_filename(self, basename: str, strip_dir: Literal[0, False] = 0, output_dir: StrPath = ...) -> str: ...
@overload
def shared_object_filename(self, basename: StrPath, strip_dir: Literal[1, True], output_dir: StrPath = ...) -> str: ...
def execute(self, func: Callable[..., object], args: tuple[Any, ...], msg: str | None = ..., level: int = ...) -> None: ...
def execute(
self, func: Callable[[Unpack[_Ts]], Unused], args: tuple[Unpack[_Ts]], msg: str | None = ..., level: int = ...
) -> None: ...
def spawn(self, cmd: list[str]) -> None: ...
def mkpath(self, name: str, mode: int = ...) -> None: ...
@overload

View File

@@ -1,12 +1,14 @@
from _typeshed import BytesPath, Incomplete, StrOrBytesPath, StrPath, Unused
from _typeshed import BytesPath, StrOrBytesPath, StrPath, Unused
from abc import abstractmethod
from collections.abc import Callable, Iterable
from typing import Any, ClassVar, TypeVar, overload
from typing_extensions import TypeVarTuple, Unpack
from .dist import Distribution
_StrPathT = TypeVar("_StrPathT", bound=StrPath)
_BytesPathT = TypeVar("_BytesPathT", bound=BytesPath)
_Ts = TypeVarTuple("_Ts")
class Command:
distribution: Distribution
@@ -34,7 +36,7 @@ class Command:
def get_sub_commands(self) -> list[str]: ...
def warn(self, msg: str) -> None: ...
def execute(
self, func: Callable[..., object], args: Iterable[Incomplete], msg: str | None = ..., level: int = ...
self, func: Callable[[Unpack[_Ts]], Unused], args: tuple[Unpack[_Ts]], msg: str | None = ..., level: int = ...
) -> None: ...
def mkpath(self, name: str, mode: int = ...) -> None: ...
@overload
@@ -95,8 +97,8 @@ class Command:
self,
infiles: str | list[str] | tuple[str, ...],
outfile: StrOrBytesPath,
func: Callable[..., object],
args: list[Incomplete],
func: Callable[[Unpack[_Ts]], Unused],
args: tuple[Unpack[_Ts]],
exec_msg: str | None = None,
skip_msg: str | None = None,
level: Unused = 1,

View File

@@ -1,5 +1,9 @@
from _typeshed import Unused
from collections.abc import Callable, Mapping
from typing import Any, Literal
from typing import Literal
from typing_extensions import TypeVarTuple, Unpack
_Ts = TypeVarTuple("_Ts")
def get_host_platform() -> str: ...
def get_platform() -> str: ...
@@ -13,7 +17,11 @@ 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 = False, dry_run: bool = False
func: Callable[[Unpack[_Ts]], Unused],
args: tuple[Unpack[_Ts]],
msg: str | None = ...,
verbose: bool = False,
dry_run: bool = False,
) -> None: ...
def strtobool(val: str) -> Literal[0, 1]: ...
def byte_compile(