Skip to content

Commit efcacfb

Browse files
authored
[setuptools] setuptools._distutils: spawn functions should match each other + add overload based on search_path` param (#15154)
1 parent 671432e commit efcacfb

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

stubs/setuptools/setuptools/_distutils/cmd.pyi

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from _typeshed import BytesPath, StrOrBytesPath, StrPath, Unused
22
from abc import abstractmethod
3-
from collections.abc import Callable, MutableSequence
4-
from typing import Any, ClassVar, TypeVar, overload
3+
from collections.abc import Callable, MutableSequence, Sequence
4+
from typing import Any, ClassVar, Literal, TypeVar, overload
55
from typing_extensions import TypeVarTuple, Unpack
66

77
from .dist import Distribution
@@ -84,7 +84,10 @@ class Command:
8484
def move_file(self, src: StrPath, dst: _StrPathT, level: Unused = 1) -> _StrPathT | str: ...
8585
@overload
8686
def move_file(self, src: BytesPath, dst: _BytesPathT, level: Unused = 1) -> _BytesPathT | bytes: ...
87-
def spawn(self, cmd: MutableSequence[str], search_path: bool = True, level: Unused = 1) -> None: ...
87+
@overload
88+
def spawn(self, cmd: Sequence[StrOrBytesPath], search_path: Literal[False], level: Unused = 1) -> None: ...
89+
@overload
90+
def spawn(self, cmd: MutableSequence[bytes | StrPath], search_path: Literal[True] = True, level: Unused = 1) -> None: ...
8891
@overload
8992
def make_archive(
9093
self,

stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from _typeshed import BytesPath, Incomplete, StrPath, Unused
1+
from _typeshed import BytesPath, Incomplete, StrOrBytesPath, StrPath, Unused
22
from collections.abc import Callable, Iterable, MutableSequence, Sequence
3+
from subprocess import _ENV
34
from typing import ClassVar, Final, Literal, TypeVar, overload
45
from typing_extensions import TypeAlias, TypeVarTuple, Unpack
56

@@ -172,7 +173,12 @@ class Compiler:
172173
def execute(
173174
self, func: Callable[[Unpack[_Ts]], Unused], args: tuple[Unpack[_Ts]], msg: str | None = None, level: int = 1
174175
) -> None: ...
175-
def spawn(self, cmd: MutableSequence[bytes | StrPath]) -> None: ...
176+
@overload
177+
def spawn(self, cmd: Sequence[StrOrBytesPath], *, search_path: Literal[False], env: _ENV | None = None) -> None: ...
178+
@overload
179+
def spawn(
180+
self, cmd: MutableSequence[bytes | StrPath], *, search_path: Literal[True] = True, env: _ENV | None = None
181+
) -> None: ...
176182
def mkpath(self, name: str, mode: int = 0o777) -> None: ...
177183
@overload
178184
def move_file(self, src: StrPath, dst: _StrPathT) -> _StrPathT | str: ...

stubs/setuptools/setuptools/_distutils/compilers/C/msvc.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from _typeshed import StrPath
2+
from collections.abc import Sequence
13
from typing import ClassVar, Final
24

35
from . import base
@@ -17,3 +19,4 @@ class Compiler(base.Compiler):
1719
def initialize(self, plat_name: str | None = None) -> None: ...
1820
@property
1921
def out_extensions(self) -> dict[str, str]: ...
22+
def spawn(self, cmd: Sequence[bytes | StrPath]): ... # type: ignore[override] # Less params

stubs/setuptools/setuptools/_distutils/spawn.pyi

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
1-
from _typeshed import StrPath
2-
from collections.abc import MutableSequence
1+
from _typeshed import StrOrBytesPath, StrPath, Unused
2+
from collections.abc import MutableSequence, Sequence
33
from subprocess import _ENV
4+
from typing import Literal, overload
45

6+
@overload
7+
def spawn(
8+
cmd: Sequence[StrOrBytesPath],
9+
search_path: Literal[False],
10+
verbose: Unused = False,
11+
dry_run: bool = False,
12+
env: _ENV | None = None,
13+
) -> None: ...
14+
@overload
515
def spawn(
616
cmd: MutableSequence[bytes | StrPath],
7-
search_path: bool = True,
8-
verbose: bool = False,
17+
search_path: Literal[True] = True,
18+
verbose: Unused = False,
919
dry_run: bool = False,
1020
env: _ENV | None = None,
1121
) -> None: ...

0 commit comments

Comments
 (0)