[setuptools] setuptools._distutils: spawn functions should match each other + add overload based on search_path` param (#15154)

This commit is contained in:
Avasam
2025-12-20 13:37:47 -05:00
committed by GitHub
parent 671432eb09
commit efcacfbded
4 changed files with 31 additions and 9 deletions
@@ -1,7 +1,7 @@
from _typeshed import BytesPath, StrOrBytesPath, StrPath, Unused
from abc import abstractmethod
from collections.abc import Callable, MutableSequence
from typing import Any, ClassVar, TypeVar, overload
from collections.abc import Callable, MutableSequence, Sequence
from typing import Any, ClassVar, Literal, TypeVar, overload
from typing_extensions import TypeVarTuple, Unpack
from .dist import Distribution
@@ -84,7 +84,10 @@ class Command:
def move_file(self, src: StrPath, dst: _StrPathT, level: Unused = 1) -> _StrPathT | str: ...
@overload
def move_file(self, src: BytesPath, dst: _BytesPathT, level: Unused = 1) -> _BytesPathT | bytes: ...
def spawn(self, cmd: MutableSequence[str], search_path: bool = True, level: Unused = 1) -> None: ...
@overload
def spawn(self, cmd: Sequence[StrOrBytesPath], search_path: Literal[False], level: Unused = 1) -> None: ...
@overload
def spawn(self, cmd: MutableSequence[bytes | StrPath], search_path: Literal[True] = True, level: Unused = 1) -> None: ...
@overload
def make_archive(
self,
@@ -1,5 +1,6 @@
from _typeshed import BytesPath, Incomplete, StrPath, Unused
from _typeshed import BytesPath, Incomplete, StrOrBytesPath, StrPath, Unused
from collections.abc import Callable, Iterable, MutableSequence, Sequence
from subprocess import _ENV
from typing import ClassVar, Final, Literal, TypeVar, overload
from typing_extensions import TypeAlias, TypeVarTuple, Unpack
@@ -172,7 +173,12 @@ class Compiler:
def execute(
self, func: Callable[[Unpack[_Ts]], Unused], args: tuple[Unpack[_Ts]], msg: str | None = None, level: int = 1
) -> None: ...
def spawn(self, cmd: MutableSequence[bytes | StrPath]) -> None: ...
@overload
def spawn(self, cmd: Sequence[StrOrBytesPath], *, search_path: Literal[False], env: _ENV | None = None) -> None: ...
@overload
def spawn(
self, cmd: MutableSequence[bytes | StrPath], *, search_path: Literal[True] = True, env: _ENV | None = None
) -> None: ...
def mkpath(self, name: str, mode: int = 0o777) -> None: ...
@overload
def move_file(self, src: StrPath, dst: _StrPathT) -> _StrPathT | str: ...
@@ -1,3 +1,5 @@
from _typeshed import StrPath
from collections.abc import Sequence
from typing import ClassVar, Final
from . import base
@@ -17,3 +19,4 @@ class Compiler(base.Compiler):
def initialize(self, plat_name: str | None = None) -> None: ...
@property
def out_extensions(self) -> dict[str, str]: ...
def spawn(self, cmd: Sequence[bytes | StrPath]): ... # type: ignore[override] # Less params
@@ -1,11 +1,21 @@
from _typeshed import StrPath
from collections.abc import MutableSequence
from _typeshed import StrOrBytesPath, StrPath, Unused
from collections.abc import MutableSequence, Sequence
from subprocess import _ENV
from typing import Literal, overload
@overload
def spawn(
cmd: Sequence[StrOrBytesPath],
search_path: Literal[False],
verbose: Unused = False,
dry_run: bool = False,
env: _ENV | None = None,
) -> None: ...
@overload
def spawn(
cmd: MutableSequence[bytes | StrPath],
search_path: bool = True,
verbose: bool = False,
search_path: Literal[True] = True,
verbose: Unused = False,
dry_run: bool = False,
env: _ENV | None = None,
) -> None: ...