mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
Fix return type of shutil.which (#6867)
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
@@ -3,7 +3,8 @@ import sys
|
||||
from _typeshed import BytesPath, StrOrBytesPath, StrPath, SupportsRead, SupportsWrite
|
||||
from typing import Any, AnyStr, Callable, Iterable, NamedTuple, Sequence, TypeVar, Union, overload
|
||||
|
||||
_PathT = TypeVar("_PathT", str, bytes, os.PathLike[str], os.PathLike[bytes])
|
||||
_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 = Any
|
||||
@@ -16,7 +17,7 @@ class ReadError(OSError): ...
|
||||
class RegistryError(Exception): ...
|
||||
|
||||
def copyfileobj(fsrc: SupportsRead[AnyStr], fdst: SupportsWrite[AnyStr], length: int = ...) -> None: ...
|
||||
def copyfile(src: StrOrBytesPath, dst: _PathT, *, follow_symlinks: bool = ...) -> _PathT: ...
|
||||
def copyfile(src: StrOrBytesPath, dst: _StrOrBytesPathT, *, follow_symlinks: bool = ...) -> _StrOrBytesPathT: ...
|
||||
def copymode(src: StrOrBytesPath, dst: StrOrBytesPath, *, follow_symlinks: bool = ...) -> None: ...
|
||||
def copystat(src: StrOrBytesPath, dst: StrOrBytesPath, *, follow_symlinks: bool = ...) -> None: ...
|
||||
@overload
|
||||
@@ -78,12 +79,12 @@ def chown(path: StrOrBytesPath, user: str | int, group: str | int) -> None: ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
@overload
|
||||
def which(cmd: StrPath, mode: int = ..., path: StrPath | None = ...) -> str | None: ...
|
||||
def which(cmd: _StrPathT, mode: int = ..., path: StrPath | None = ...) -> str | _StrPathT | None: ...
|
||||
@overload
|
||||
def which(cmd: bytes, mode: int = ..., path: StrPath | None = ...) -> bytes | None: ...
|
||||
|
||||
else:
|
||||
def which(cmd: StrPath, mode: int = ..., path: StrPath | None = ...) -> str | None: ...
|
||||
def which(cmd: _StrPathT, mode: int = ..., path: StrPath | None = ...) -> str | _StrPathT | None: ...
|
||||
|
||||
def make_archive(
|
||||
base_name: str,
|
||||
|
||||
Reference in New Issue
Block a user