From aad57727fc20588daac9f40031a10cb2762cc5cd Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 4 Mar 2025 13:37:51 -0500 Subject: [PATCH 1/2] shutil.which cannot return PathLike --- stdlib/shutil.pyi | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/stdlib/shutil.pyi b/stdlib/shutil.pyi index 4a19a96a306c..3f4292537efa 100644 --- a/stdlib/shutil.pyi +++ b/stdlib/shutil.pyi @@ -3,7 +3,7 @@ import sys from _typeshed import BytesPath, ExcInfo, FileDescriptorOrPath, StrOrBytesPath, StrPath, SupportsRead, SupportsWrite from collections.abc import Callable, Iterable, Sequence from tarfile import _TarfileFilter -from typing import Any, AnyStr, NamedTuple, Protocol, TypeVar, overload +from typing import Any, AnyStr, NamedTuple, NoReturn, Protocol, TypeVar, overload from typing_extensions import TypeAlias, deprecated __all__ = [ @@ -185,8 +185,13 @@ else: @overload def chown(path: FileDescriptorOrPath, user: str | int, group: str | int) -> None: ... +if sys.platform == "win32" and sys.version_info < (3, 12): + @overload + @deprecated("On Windows before Python 3.12, using a PathLike as `cmd` would always fail or return `None`.") + def which(cmd: os.PathLike[str], mode: int = 1, path: StrPath | None = None) -> NoReturn: ... + @overload -def which(cmd: _StrPathT, mode: int = 1, path: StrPath | None = None) -> str | _StrPathT | None: ... +def which(cmd: StrPath, mode: int = 1, path: StrPath | None = None) -> str | None: ... @overload def which(cmd: bytes, mode: int = 1, path: StrPath | None = None) -> bytes | None: ... def make_archive( From fa7646b06967523e676691c1ba573be3af80ff8c Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 4 Mar 2025 14:06:10 -0500 Subject: [PATCH 2/2] Remove unused variable --- stdlib/shutil.pyi | 1 - 1 file changed, 1 deletion(-) diff --git a/stdlib/shutil.pyi b/stdlib/shutil.pyi index 3f4292537efa..0fe560fd9b6a 100644 --- a/stdlib/shutil.pyi +++ b/stdlib/shutil.pyi @@ -36,7 +36,6 @@ __all__ = [ ] _StrOrBytesPathT = TypeVar("_StrOrBytesPathT", bound=StrOrBytesPath) -_StrPathT = TypeVar("_StrPathT", bound=StrPath) # Return value of some functions that may either return a path-like object that was passed in or # a string _PathReturn: TypeAlias = Any