From efcacfbded5951c6f6c5288a8935d4cc9f81605c Mon Sep 17 00:00:00 2001 From: Avasam Date: Sat, 20 Dec 2025 13:37:47 -0500 Subject: [PATCH] [setuptools] setuptools._distutils`: spawn functions should match each other + add overload based on `search_path` param (#15154) --- stubs/setuptools/setuptools/_distutils/cmd.pyi | 9 ++++++--- .../setuptools/_distutils/compilers/C/base.pyi | 10 ++++++++-- .../setuptools/_distutils/compilers/C/msvc.pyi | 3 +++ .../setuptools/setuptools/_distutils/spawn.pyi | 18 ++++++++++++++---- 4 files changed, 31 insertions(+), 9 deletions(-) diff --git a/stubs/setuptools/setuptools/_distutils/cmd.pyi b/stubs/setuptools/setuptools/_distutils/cmd.pyi index 2c22e4609..036bb0844 100644 --- a/stubs/setuptools/setuptools/_distutils/cmd.pyi +++ b/stubs/setuptools/setuptools/_distutils/cmd.pyi @@ -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, diff --git a/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi b/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi index f33e86e6b..8f51b6790 100644 --- a/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi +++ b/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi @@ -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: ... diff --git a/stubs/setuptools/setuptools/_distutils/compilers/C/msvc.pyi b/stubs/setuptools/setuptools/_distutils/compilers/C/msvc.pyi index 44f5c85b8..ad2f16eb7 100644 --- a/stubs/setuptools/setuptools/_distutils/compilers/C/msvc.pyi +++ b/stubs/setuptools/setuptools/_distutils/compilers/C/msvc.pyi @@ -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 diff --git a/stubs/setuptools/setuptools/_distutils/spawn.pyi b/stubs/setuptools/setuptools/_distutils/spawn.pyi index 259a3a99d..9b725d43a 100644 --- a/stubs/setuptools/setuptools/_distutils/spawn.pyi +++ b/stubs/setuptools/setuptools/_distutils/spawn.pyi @@ -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: ...