From b0b1402de581ccb7744c94b6f81774c143b9f10f Mon Sep 17 00:00:00 2001 From: Avasam Date: Sat, 20 Dec 2025 00:18:14 -0500 Subject: [PATCH 1/5] setuptools: spawn functions should match each other --- stubs/setuptools/setuptools/_distutils/cmd.pyi | 9 ++++++--- .../setuptools/_distutils/compilers/C/base.pyi | 16 ++++++++++++++-- .../setuptools/setuptools/_distutils/spawn.pyi | 18 ++++++++++++++---- 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/stubs/setuptools/setuptools/_distutils/cmd.pyi b/stubs/setuptools/setuptools/_distutils/cmd.pyi index 2c22e460989c..036bb08441f8 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 f33e86e6ba9f..61b86963d3eb 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,18 @@ 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], verbose: Unused = False, env: _ENV | None = None + ) -> None: ... + @overload + def spawn( + self, + cmd: MutableSequence[bytes | StrPath], + search_path: Literal[True] = True, + verbose: Unused = False, + 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/spawn.pyi b/stubs/setuptools/setuptools/_distutils/spawn.pyi index 259a3a99d23b..9b725d43a63d 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: ... From a9fcd3a6890061013adc8915658468ffdfd1764d Mon Sep 17 00:00:00 2001 From: Avasam Date: Sat, 20 Dec 2025 00:47:48 -0500 Subject: [PATCH 2/5] Must be kwargs --- stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi b/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi index 61b86963d3eb..43d39766f92e 100644 --- a/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi +++ b/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi @@ -175,12 +175,13 @@ class Compiler: ) -> None: ... @overload def spawn( - self, cmd: Sequence[StrOrBytesPath], search_path: Literal[False], verbose: Unused = False, env: _ENV | None = None + self, cmd: Sequence[StrOrBytesPath], *, search_path: Literal[False], verbose: Unused = False, env: _ENV | None = None ) -> None: ... @overload def spawn( self, cmd: MutableSequence[bytes | StrPath], + *, search_path: Literal[True] = True, verbose: Unused = False, env: _ENV | None = None, From 219a2a80064d2e37e93854bef706a47f7c6d1fa4 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sat, 20 Dec 2025 00:52:20 -0500 Subject: [PATCH 3/5] Add missing MSVC override --- stubs/setuptools/setuptools/_distutils/compilers/C/msvc.pyi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stubs/setuptools/setuptools/_distutils/compilers/C/msvc.pyi b/stubs/setuptools/setuptools/_distutils/compilers/C/msvc.pyi index 44f5c85b8be3..e86cab9a5568 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]): ... From 7effca84119adc379e3958fd36e03e7d3457a9d6 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sat, 20 Dec 2025 01:05:17 -0500 Subject: [PATCH 4/5] Add type ignore --- stubs/setuptools/setuptools/_distutils/compilers/C/msvc.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stubs/setuptools/setuptools/_distutils/compilers/C/msvc.pyi b/stubs/setuptools/setuptools/_distutils/compilers/C/msvc.pyi index e86cab9a5568..ad2f16eb7d14 100644 --- a/stubs/setuptools/setuptools/_distutils/compilers/C/msvc.pyi +++ b/stubs/setuptools/setuptools/_distutils/compilers/C/msvc.pyi @@ -19,4 +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]): ... + def spawn(self, cmd: Sequence[bytes | StrPath]): ... # type: ignore[override] # Less params From fc4bfd79a366e29e6a1d2aaf802966e4a7d894b1 Mon Sep 17 00:00:00 2001 From: Avasam Date: Sat, 20 Dec 2025 11:49:16 -0500 Subject: [PATCH 5/5] drop unused kw-only arg --- .../setuptools/_distutils/compilers/C/base.pyi | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi b/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi index 43d39766f92e..8f51b6790596 100644 --- a/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi +++ b/stubs/setuptools/setuptools/_distutils/compilers/C/base.pyi @@ -174,17 +174,10 @@ class Compiler: self, func: Callable[[Unpack[_Ts]], Unused], args: tuple[Unpack[_Ts]], msg: str | None = None, level: int = 1 ) -> None: ... @overload - def spawn( - self, cmd: Sequence[StrOrBytesPath], *, search_path: Literal[False], verbose: Unused = False, env: _ENV | None = None - ) -> None: ... + 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, - verbose: Unused = False, - env: _ENV | None = None, + 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