diff --git a/stdlib/@python2/_typeshed/__init__.pyi b/stdlib/@python2/_typeshed/__init__.pyi index 1d1442d58..9548a2497 100644 --- a/stdlib/@python2/_typeshed/__init__.pyi +++ b/stdlib/@python2/_typeshed/__init__.pyi @@ -57,11 +57,12 @@ class SupportsItemAccess(SupportsGetItem[_KT_contra, _VT], Protocol[_KT_contra, def __setitem__(self, __k: _KT_contra, __v: _VT) -> None: ... def __delitem__(self, __v: _KT_contra) -> None: ... -# StrPath and AnyPath can be used in places where a -# path can be used instead of a string, starting with Python 3.6. +# These aliases can be used in places where a PathLike object can be used +# instead of a string in Python 3. StrPath = Text -BytesPath = bytes -AnyPath = Union[Text, bytes] +BytesPath = str +StrOrBytesPath = Text +AnyPath = StrOrBytesPath # obsolete, will be removed soon OpenTextModeUpdating = Literal[ "r+", diff --git a/stdlib/@python2/bz2.pyi b/stdlib/@python2/bz2.pyi index 17d1194cd..d3c0baded 100644 --- a/stdlib/@python2/bz2.pyi +++ b/stdlib/@python2/bz2.pyi @@ -1,9 +1,9 @@ import io -from _typeshed import AnyPath, ReadableBuffer, WriteableBuffer -from typing import IO, Any, Iterable, List, Optional, TypeVar, Union +from _typeshed import ReadableBuffer, WriteableBuffer +from typing import IO, Any, Iterable, List, Optional, Text, TypeVar, Union from typing_extensions import SupportsIndex -_PathOrFile = Union[AnyPath, IO[bytes]] +_PathOrFile = Union[Text, IO[bytes]] _T = TypeVar("_T") def compress(data: bytes, compresslevel: int = ...) -> bytes: ... diff --git a/stdlib/@python2/cProfile.pyi b/stdlib/@python2/cProfile.pyi index b7255a2d9..0cc2e9498 100644 --- a/stdlib/@python2/cProfile.pyi +++ b/stdlib/@python2/cProfile.pyi @@ -1,6 +1,5 @@ -from _typeshed import AnyPath from types import CodeType -from typing import Any, Callable, Dict, Optional, Tuple, TypeVar, Union +from typing import Any, Callable, Dict, Optional, Text, Tuple, TypeVar, Union def run(statement: str, filename: Optional[str] = ..., sort: Union[str, int] = ...) -> None: ... def runctx( @@ -19,7 +18,7 @@ class Profile: def enable(self) -> None: ... def disable(self) -> None: ... def print_stats(self, sort: Union[str, int] = ...) -> None: ... - def dump_stats(self, file: AnyPath) -> None: ... + def dump_stats(self, file: Text) -> None: ... def create_stats(self) -> None: ... def snapshot_stats(self) -> None: ... def run(self: _SelfT, cmd: str) -> _SelfT: ... diff --git a/stdlib/@python2/cgitb.pyi b/stdlib/@python2/cgitb.pyi index 7603ecd9a..017840dc4 100644 --- a/stdlib/@python2/cgitb.pyi +++ b/stdlib/@python2/cgitb.pyi @@ -1,6 +1,5 @@ -from _typeshed import AnyPath from types import FrameType, TracebackType -from typing import IO, Any, Callable, Dict, List, Optional, Tuple, Type +from typing import IO, Any, Callable, Dict, List, Optional, Text, Tuple, Type _ExcInfo = Tuple[Optional[Type[BaseException]], Optional[BaseException], Optional[TracebackType]] @@ -19,7 +18,7 @@ class Hook: # undocumented def __init__( self, display: int = ..., - logdir: Optional[AnyPath] = ..., + logdir: Optional[Text] = ..., context: int = ..., file: Optional[IO[str]] = ..., format: str = ..., @@ -30,4 +29,4 @@ class Hook: # undocumented def handle(self, info: Optional[_ExcInfo] = ...) -> None: ... def handler(info: Optional[_ExcInfo] = ...) -> None: ... -def enable(display: int = ..., logdir: Optional[AnyPath] = ..., context: int = ..., format: str = ...) -> None: ... +def enable(display: int = ..., logdir: Optional[Text] = ..., context: int = ..., format: str = ...) -> None: ... diff --git a/stdlib/@python2/compileall.pyi b/stdlib/@python2/compileall.pyi index 59680fd79..5ae1d6f7f 100644 --- a/stdlib/@python2/compileall.pyi +++ b/stdlib/@python2/compileall.pyi @@ -1,16 +1,15 @@ -from _typeshed import AnyPath -from typing import Any, Optional, Pattern +from typing import Any, Optional, Pattern, Text # rx can be any object with a 'search' method; once we have Protocols we can change the type def compile_dir( - dir: AnyPath, + dir: Text, maxlevels: int = ..., - ddir: Optional[AnyPath] = ..., + ddir: Optional[Text] = ..., force: bool = ..., rx: Optional[Pattern[Any]] = ..., quiet: int = ..., ) -> int: ... def compile_file( - fullname: AnyPath, ddir: Optional[AnyPath] = ..., force: bool = ..., rx: Optional[Pattern[Any]] = ..., quiet: int = ... + fullname: Text, ddir: Optional[Text] = ..., force: bool = ..., rx: Optional[Pattern[Any]] = ..., quiet: int = ... ) -> int: ... def compile_path(skip_curdir: bool = ..., maxlevels: int = ..., force: bool = ..., quiet: int = ...) -> int: ... diff --git a/stdlib/@python2/fileinput.pyi b/stdlib/@python2/fileinput.pyi index 8bea5ce77..1e1f8dace 100644 --- a/stdlib/@python2/fileinput.pyi +++ b/stdlib/@python2/fileinput.pyi @@ -1,13 +1,12 @@ -from _typeshed import AnyPath -from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Union +from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Text, Union def input( - files: Union[AnyPath, Iterable[AnyPath], None] = ..., + files: Union[Text, Iterable[Text], None] = ..., inplace: bool = ..., backup: str = ..., bufsize: int = ..., mode: str = ..., - openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., + openhook: Callable[[Text, str], IO[AnyStr]] = ..., ) -> FileInput[AnyStr]: ... def close() -> None: ... def nextfile() -> None: ... @@ -21,12 +20,12 @@ def isstdin() -> bool: ... class FileInput(Iterable[AnyStr], Generic[AnyStr]): def __init__( self, - files: Union[None, AnyPath, Iterable[AnyPath]] = ..., + files: Union[None, Text, Iterable[Text]] = ..., inplace: bool = ..., backup: str = ..., bufsize: int = ..., mode: str = ..., - openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., + openhook: Callable[[Text, str], IO[AnyStr]] = ..., ) -> None: ... def __del__(self) -> None: ... def close(self) -> None: ... @@ -42,5 +41,5 @@ class FileInput(Iterable[AnyStr], Generic[AnyStr]): def isfirstline(self) -> bool: ... def isstdin(self) -> bool: ... -def hook_compressed(filename: AnyPath, mode: str) -> IO[Any]: ... -def hook_encoded(encoding: str) -> Callable[[AnyPath, str], IO[Any]]: ... +def hook_compressed(filename: Text, mode: str) -> IO[Any]: ... +def hook_encoded(encoding: str) -> Callable[[Text, str], IO[Any]]: ... diff --git a/stdlib/@python2/genericpath.pyi b/stdlib/@python2/genericpath.pyi index 34bc57e2e..72e6b7a24 100644 --- a/stdlib/@python2/genericpath.pyi +++ b/stdlib/@python2/genericpath.pyi @@ -1,25 +1,25 @@ -from _typeshed import AnyPath, BytesPath, StrPath, SupportsLessThanT -from typing import List, Sequence, Tuple, Union, overload +from _typeshed import SupportsLessThanT +from typing import List, Sequence, Text, Tuple, Union, overload from typing_extensions import Literal # All overloads can return empty string. Ideally, Literal[""] would be a valid # Iterable[T], so that Union[List[T], Literal[""]] could be used as a return # type. But because this only works when T is str, we need Sequence[T] instead. @overload -def commonprefix(m: Sequence[StrPath]) -> str: ... # type: ignore +def commonprefix(m: Sequence[Text]) -> str: ... # type: ignore @overload -def commonprefix(m: Sequence[BytesPath]) -> Union[bytes, Literal[""]]: ... # type: ignore +def commonprefix(m: Sequence[str]) -> Union[str, Literal[""]]: ... # type: ignore @overload def commonprefix(m: Sequence[List[SupportsLessThanT]]) -> Sequence[SupportsLessThanT]: ... @overload def commonprefix(m: Sequence[Tuple[SupportsLessThanT, ...]]) -> Sequence[SupportsLessThanT]: ... -def exists(path: AnyPath) -> bool: ... -def getsize(filename: AnyPath) -> int: ... -def isfile(path: AnyPath) -> bool: ... -def isdir(s: AnyPath) -> bool: ... +def exists(path: Text) -> bool: ... +def getsize(filename: Text) -> int: ... +def isfile(path: Text) -> bool: ... +def isdir(s: Text) -> bool: ... # These return float if os.stat_float_times() == True, # but int is a subclass of float. -def getatime(filename: AnyPath) -> float: ... -def getmtime(filename: AnyPath) -> float: ... -def getctime(filename: AnyPath) -> float: ... +def getatime(filename: Text) -> float: ... +def getmtime(filename: Text) -> float: ... +def getctime(filename: Text) -> float: ... diff --git a/stdlib/@python2/macpath.pyi b/stdlib/@python2/macpath.pyi index b65234ed5..74e3315f6 100644 --- a/stdlib/@python2/macpath.pyi +++ b/stdlib/@python2/macpath.pyi @@ -1,4 +1,3 @@ -from _typeshed import AnyPath from genericpath import ( commonprefix as commonprefix, exists as exists, @@ -37,7 +36,7 @@ def dirname(s: AnyStr) -> AnyStr: ... def normcase(path: AnyStr) -> AnyStr: ... def normpath(s: AnyStr) -> AnyStr: ... def realpath(path: AnyStr) -> AnyStr: ... -def islink(s: AnyPath) -> bool: ... +def islink(s: Text) -> bool: ... # Make sure signatures are disjunct, and allow combinations of bytes and unicode. # (Since Python 2 allows that, too) @@ -46,11 +45,11 @@ def islink(s: AnyPath) -> bool: ... @overload def join(__p1: bytes, *p: bytes) -> bytes: ... @overload -def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: AnyPath) -> Text: ... +def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: Text) -> Text: ... @overload -def join(__p1: bytes, __p2: bytes, __p3: Text, *p: AnyPath) -> Text: ... +def join(__p1: bytes, __p2: bytes, __p3: Text, *p: Text) -> Text: ... @overload -def join(__p1: bytes, __p2: Text, *p: AnyPath) -> Text: ... +def join(__p1: bytes, __p2: Text, *p: Text) -> Text: ... @overload -def join(__p1: Text, *p: AnyPath) -> Text: ... +def join(__p1: Text, *p: Text) -> Text: ... def split(s: AnyStr) -> Tuple[AnyStr, AnyStr]: ... diff --git a/stdlib/@python2/mailbox.pyi b/stdlib/@python2/mailbox.pyi index db93b78d6..38663a391 100644 --- a/stdlib/@python2/mailbox.pyi +++ b/stdlib/@python2/mailbox.pyi @@ -1,5 +1,4 @@ import email.message -from _typeshed import AnyPath from types import TracebackType from typing import ( IO, @@ -40,7 +39,7 @@ class Mailbox(Generic[_MessageT]): _path: Union[bytes, str] # undocumented _factory: Optional[Callable[[IO[Any]], _MessageT]] # undocumented - def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], _MessageT]] = ..., create: bool = ...) -> None: ... + def __init__(self, path: Text, factory: Optional[Callable[[IO[Any]], _MessageT]] = ..., create: bool = ...) -> None: ... def add(self, message: _MessageData) -> str: ... def remove(self, key: str) -> None: ... def __delitem__(self, key: str) -> None: ... @@ -81,7 +80,7 @@ class Maildir(Mailbox[MaildirMessage]): colon: str def __init__( - self, dirname: AnyPath, factory: Optional[Callable[[IO[Any]], MaildirMessage]] = ..., create: bool = ... + self, dirname: Text, factory: Optional[Callable[[IO[Any]], MaildirMessage]] = ..., create: bool = ... ) -> None: ... def get_file(self, key: str) -> _ProxyFile[bytes]: ... def list_folders(self) -> List[str]: ... @@ -99,24 +98,24 @@ class _mboxMMDF(_singlefileMailbox[_MessageT]): def get_string(self, key: str, from_: bool = ...) -> str: ... class mbox(_mboxMMDF[mboxMessage]): - def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], mboxMessage]] = ..., create: bool = ...) -> None: ... + def __init__(self, path: Text, factory: Optional[Callable[[IO[Any]], mboxMessage]] = ..., create: bool = ...) -> None: ... class MMDF(_mboxMMDF[MMDFMessage]): - def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], MMDFMessage]] = ..., create: bool = ...) -> None: ... + def __init__(self, path: Text, factory: Optional[Callable[[IO[Any]], MMDFMessage]] = ..., create: bool = ...) -> None: ... class MH(Mailbox[MHMessage]): - def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], MHMessage]] = ..., create: bool = ...) -> None: ... + def __init__(self, path: Text, factory: Optional[Callable[[IO[Any]], MHMessage]] = ..., create: bool = ...) -> None: ... def get_file(self, key: str) -> _ProxyFile[bytes]: ... def list_folders(self) -> List[str]: ... - def get_folder(self, folder: AnyPath) -> MH: ... - def add_folder(self, folder: AnyPath) -> MH: ... - def remove_folder(self, folder: AnyPath) -> None: ... + def get_folder(self, folder: Text) -> MH: ... + def add_folder(self, folder: Text) -> MH: ... + def remove_folder(self, folder: Text) -> None: ... def get_sequences(self) -> Dict[str, List[int]]: ... def set_sequences(self, sequences: Mapping[str, Sequence[int]]) -> None: ... def pack(self) -> None: ... class Babyl(_singlefileMailbox[BabylMessage]): - def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], BabylMessage]] = ..., create: bool = ...) -> None: ... + def __init__(self, path: Text, factory: Optional[Callable[[IO[Any]], BabylMessage]] = ..., create: bool = ...) -> None: ... def get_file(self, key: str) -> IO[bytes]: ... def get_labels(self) -> List[str]: ... diff --git a/stdlib/@python2/netrc.pyi b/stdlib/@python2/netrc.pyi index 20a0513ea..2ee3c5225 100644 --- a/stdlib/@python2/netrc.pyi +++ b/stdlib/@python2/netrc.pyi @@ -1,11 +1,10 @@ -from _typeshed import AnyPath -from typing import Dict, List, Optional, Tuple +from typing import Dict, List, Optional, Text, Tuple class NetrcParseError(Exception): filename: Optional[str] lineno: Optional[int] msg: str - def __init__(self, msg: str, filename: Optional[AnyPath] = ..., lineno: Optional[int] = ...) -> None: ... + def __init__(self, msg: str, filename: Optional[Text] = ..., lineno: Optional[int] = ...) -> None: ... # (login, account, password) tuple _NetrcTuple = Tuple[str, Optional[str], Optional[str]] @@ -13,5 +12,5 @@ _NetrcTuple = Tuple[str, Optional[str], Optional[str]] class netrc: hosts: Dict[str, _NetrcTuple] macros: Dict[str, List[str]] - def __init__(self, file: Optional[AnyPath] = ...) -> None: ... + def __init__(self, file: Optional[Text] = ...) -> None: ... def authenticators(self, host: str) -> Optional[_NetrcTuple]: ... diff --git a/stdlib/@python2/ntpath.pyi b/stdlib/@python2/ntpath.pyi index f09642860..07bd9653e 100644 --- a/stdlib/@python2/ntpath.pyi +++ b/stdlib/@python2/ntpath.pyi @@ -1,6 +1,5 @@ import os import sys -from _typeshed import AnyPath, BytesPath, StrPath from genericpath import exists as exists from typing import Any, AnyStr, Callable, List, Optional, Sequence, Text, Tuple, TypeVar, overload @@ -39,20 +38,20 @@ else: # NOTE: Empty lists results in '' (str) regardless of contained type. # Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes # So, fall back to Any -def commonprefix(m: Sequence[AnyPath]) -> Any: ... -def lexists(path: AnyPath) -> bool: ... +def commonprefix(m: Sequence[Text]) -> Any: ... +def lexists(path: Text) -> bool: ... # These return float if os.stat_float_times() == True, # but int is a subclass of float. -def getatime(filename: AnyPath) -> float: ... -def getmtime(filename: AnyPath) -> float: ... -def getctime(filename: AnyPath) -> float: ... -def getsize(filename: AnyPath) -> int: ... -def isabs(s: AnyPath) -> bool: ... -def isfile(path: AnyPath) -> bool: ... -def isdir(s: AnyPath) -> bool: ... -def islink(path: AnyPath) -> bool: ... -def ismount(path: AnyPath) -> bool: ... +def getatime(filename: Text) -> float: ... +def getmtime(filename: Text) -> float: ... +def getctime(filename: Text) -> float: ... +def getsize(filename: Text) -> int: ... +def isabs(s: Text) -> bool: ... +def isfile(path: Text) -> bool: ... +def isdir(s: Text) -> bool: ... +def islink(path: Text) -> bool: ... +def ismount(path: Text) -> bool: ... # Make sure signatures are disjunct, and allow combinations of bytes and unicode. # (Since Python 2 allows that, too) @@ -61,18 +60,18 @@ def ismount(path: AnyPath) -> bool: ... @overload def join(__p1: bytes, *p: bytes) -> bytes: ... @overload -def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: AnyPath) -> Text: ... +def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: Text) -> Text: ... @overload -def join(__p1: bytes, __p2: bytes, __p3: Text, *p: AnyPath) -> Text: ... +def join(__p1: bytes, __p2: bytes, __p3: Text, *p: Text) -> Text: ... @overload -def join(__p1: bytes, __p2: Text, *p: AnyPath) -> Text: ... +def join(__p1: bytes, __p2: Text, *p: Text) -> Text: ... @overload -def join(__p1: Text, *p: AnyPath) -> Text: ... +def join(__p1: Text, *p: Text) -> Text: ... @overload -def relpath(path: BytesPath, start: Optional[BytesPath] = ...) -> bytes: ... +def relpath(path: str, start: Optional[str] = ...) -> str: ... @overload -def relpath(path: StrPath, start: Optional[StrPath] = ...) -> Text: ... -def samefile(f1: AnyPath, f2: AnyPath) -> bool: ... +def relpath(path: Text, start: Optional[Text] = ...) -> Text: ... +def samefile(f1: Text, f2: Text) -> bool: ... def sameopenfile(fp1: int, fp2: int) -> bool: ... def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... def split(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... diff --git a/stdlib/@python2/os/__init__.pyi b/stdlib/@python2/os/__init__.pyi index db96359ff..3b4f9698d 100644 --- a/stdlib/@python2/os/__init__.pyi +++ b/stdlib/@python2/os/__init__.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import AnyPath, FileDescriptorLike +from _typeshed import FileDescriptorLike from builtins import OSError from posix import listdir as listdir, stat_result as stat_result # TODO: use this, see https://github.com/python/mypy/issues/3078 from typing import ( @@ -198,40 +198,40 @@ def dup2(fd: int, fd2: int) -> None: ... def fstat(fd: int) -> Any: ... def fsync(fd: FileDescriptorLike) -> None: ... def lseek(fd: int, pos: int, how: int) -> int: ... -def open(file: AnyPath, flags: int, mode: int = ...) -> int: ... +def open(file: Text, flags: int, mode: int = ...) -> int: ... def pipe() -> Tuple[int, int]: ... def read(fd: int, n: int) -> bytes: ... def write(fd: int, string: Union[bytes, buffer]) -> int: ... -def access(path: AnyPath, mode: int) -> bool: ... -def chdir(path: AnyPath) -> None: ... +def access(path: Text, mode: int) -> bool: ... +def chdir(path: Text) -> None: ... def fchdir(fd: FileDescriptorLike) -> None: ... def getcwd() -> str: ... def getcwdu() -> unicode: ... -def chmod(path: AnyPath, mode: int) -> None: ... -def link(src: AnyPath, link_name: AnyPath) -> None: ... -def lstat(path: AnyPath) -> Any: ... -def mknod(filename: AnyPath, mode: int = ..., device: int = ...) -> None: ... +def chmod(path: Text, mode: int) -> None: ... +def link(src: Text, link_name: Text) -> None: ... +def lstat(path: Text) -> Any: ... +def mknod(filename: Text, mode: int = ..., device: int = ...) -> None: ... def major(device: int) -> int: ... def minor(device: int) -> int: ... def makedev(major: int, minor: int) -> int: ... -def mkdir(path: AnyPath, mode: int = ...) -> None: ... -def makedirs(path: AnyPath, mode: int = ...) -> None: ... +def mkdir(path: Text, mode: int = ...) -> None: ... +def makedirs(path: Text, mode: int = ...) -> None: ... def readlink(path: AnyStr) -> AnyStr: ... -def remove(path: AnyPath) -> None: ... -def removedirs(path: AnyPath) -> None: ... -def rename(src: AnyPath, dst: AnyPath) -> None: ... -def renames(old: AnyPath, new: AnyPath) -> None: ... -def rmdir(path: AnyPath) -> None: ... -def stat(path: AnyPath) -> Any: ... +def remove(path: Text) -> None: ... +def removedirs(path: Text) -> None: ... +def rename(src: Text, dst: Text) -> None: ... +def renames(old: Text, new: Text) -> None: ... +def rmdir(path: Text) -> None: ... +def stat(path: Text) -> Any: ... @overload def stat_float_times() -> bool: ... @overload def stat_float_times(newvalue: bool) -> None: ... -def symlink(source: AnyPath, link_name: AnyPath) -> None: ... -def unlink(path: AnyPath) -> None: ... +def symlink(source: Text, link_name: Text) -> None: ... +def unlink(path: Text) -> None: ... # TODO: add ns, dir_fd, follow_symlinks argument -def utime(path: AnyPath, times: Optional[Tuple[float, float]]) -> None: ... +def utime(path: Text, times: Optional[Tuple[float, float]]) -> None: ... if sys.platform != "win32": # Unix only @@ -247,15 +247,15 @@ if sys.platform != "win32": def tcgetpgrp(fd: int) -> int: ... def tcsetpgrp(fd: int, pg: int) -> None: ... def ttyname(fd: int) -> str: ... - def chflags(path: AnyPath, flags: int) -> None: ... - def chroot(path: AnyPath) -> None: ... - def chown(path: AnyPath, uid: int, gid: int) -> None: ... - def lchflags(path: AnyPath, flags: int) -> None: ... - def lchmod(path: AnyPath, mode: int) -> None: ... - def lchown(path: AnyPath, uid: int, gid: int) -> None: ... - def mkfifo(path: AnyPath, mode: int = ...) -> None: ... - def pathconf(path: AnyPath, name: Union[str, int]) -> int: ... - def statvfs(path: AnyPath) -> _StatVFS: ... + def chflags(path: Text, flags: int) -> None: ... + def chroot(path: Text) -> None: ... + def chown(path: Text, uid: int, gid: int) -> None: ... + def lchflags(path: Text, flags: int) -> None: ... + def lchmod(path: Text, mode: int) -> None: ... + def lchown(path: Text, uid: int, gid: int) -> None: ... + def mkfifo(path: Text, mode: int = ...) -> None: ... + def pathconf(path: Text, name: Union[str, int]) -> int: ... + def statvfs(path: Text) -> _StatVFS: ... def walk( top: AnyStr, topdown: bool = ..., onerror: Optional[Callable[[OSError], Any]] = ..., followlinks: bool = ... @@ -263,21 +263,21 @@ def walk( def abort() -> NoReturn: ... # These are defined as execl(file, *args) but the first *arg is mandatory. -def execl(file: AnyPath, __arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> NoReturn: ... -def execlp(file: AnyPath, __arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> NoReturn: ... +def execl(file: Text, __arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> NoReturn: ... +def execlp(file: Text, __arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> NoReturn: ... # These are: execle(file, *args, env) but env is pulled from the last element of the args. -def execle(file: AnyPath, __arg0: Union[bytes, Text], *args: Any) -> NoReturn: ... -def execlpe(file: AnyPath, __arg0: Union[bytes, Text], *args: Any) -> NoReturn: ... +def execle(file: Text, __arg0: Union[bytes, Text], *args: Any) -> NoReturn: ... +def execlpe(file: Text, __arg0: Union[bytes, Text], *args: Any) -> NoReturn: ... # The docs say `args: tuple or list of strings` # The implementation enforces tuple or list so we can't use Sequence. _ExecVArgs = Union[Tuple[Union[bytes, Text], ...], List[bytes], List[Text], List[Union[bytes, Text]]] -def execv(path: AnyPath, args: _ExecVArgs) -> NoReturn: ... -def execve(path: AnyPath, args: _ExecVArgs, env: Mapping[str, str]) -> NoReturn: ... -def execvp(file: AnyPath, args: _ExecVArgs) -> NoReturn: ... -def execvpe(file: AnyPath, args: _ExecVArgs, env: Mapping[str, str]) -> NoReturn: ... +def execv(path: Text, args: _ExecVArgs) -> NoReturn: ... +def execve(path: Text, args: _ExecVArgs, env: Mapping[str, str]) -> NoReturn: ... +def execvp(file: Text, args: _ExecVArgs) -> NoReturn: ... +def execvpe(file: Text, args: _ExecVArgs, env: Mapping[str, str]) -> NoReturn: ... def _exit(n: int) -> NoReturn: ... def kill(pid: int, sig: int) -> None: ... @@ -293,24 +293,24 @@ def popen(command: str, *args, **kwargs) -> IO[Any]: ... def popen2(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any]]: ... def popen3(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any], IO[Any]]: ... def popen4(cmd: str, *args, **kwargs) -> Tuple[IO[Any], IO[Any]]: ... -def spawnl(mode: int, path: AnyPath, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ... -def spawnle(mode: int, path: AnyPath, arg0: Union[bytes, Text], *args: Any) -> int: ... # Imprecise sig -def spawnv(mode: int, path: AnyPath, args: List[Union[bytes, Text]]) -> int: ... -def spawnve(mode: int, path: AnyPath, args: List[Union[bytes, Text]], env: Mapping[str, str]) -> int: ... -def system(command: AnyPath) -> int: ... +def spawnl(mode: int, path: Text, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ... +def spawnle(mode: int, path: Text, arg0: Union[bytes, Text], *args: Any) -> int: ... # Imprecise sig +def spawnv(mode: int, path: Text, args: List[Union[bytes, Text]]) -> int: ... +def spawnve(mode: int, path: Text, args: List[Union[bytes, Text]], env: Mapping[str, str]) -> int: ... +def system(command: Text) -> int: ... def times() -> Tuple[float, float, float, float, float]: ... def waitpid(pid: int, options: int) -> Tuple[int, int]: ... def urandom(n: int) -> bytes: ... if sys.platform == "win32": - def startfile(path: AnyPath, operation: Optional[str] = ...) -> None: ... + def startfile(path: Text, operation: Optional[str] = ...) -> None: ... else: # Unix only - def spawnlp(mode: int, file: AnyPath, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ... - def spawnlpe(mode: int, file: AnyPath, arg0: Union[bytes, Text], *args: Any) -> int: ... # Imprecise signature - def spawnvp(mode: int, file: AnyPath, args: List[Union[bytes, Text]]) -> int: ... - def spawnvpe(mode: int, file: AnyPath, args: List[Union[bytes, Text]], env: Mapping[str, str]) -> int: ... + def spawnlp(mode: int, file: Text, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ... + def spawnlpe(mode: int, file: Text, arg0: Union[bytes, Text], *args: Any) -> int: ... # Imprecise signature + def spawnvp(mode: int, file: Text, args: List[Union[bytes, Text]]) -> int: ... + def spawnvpe(mode: int, file: Text, args: List[Union[bytes, Text]], env: Mapping[str, str]) -> int: ... def wait() -> Tuple[int, int]: ... def wait3(options: int) -> Tuple[int, int, Any]: ... def wait4(pid: int, options: int) -> Tuple[int, int, Any]: ... diff --git a/stdlib/@python2/os/path.pyi b/stdlib/@python2/os/path.pyi index c89bc8b69..124385f13 100644 --- a/stdlib/@python2/os/path.pyi +++ b/stdlib/@python2/os/path.pyi @@ -1,6 +1,5 @@ import os import sys -from _typeshed import AnyPath, BytesPath, StrPath from typing import Any, AnyStr, Callable, List, Optional, Sequence, Text, Tuple, TypeVar, overload _T = TypeVar("_T") @@ -38,21 +37,21 @@ else: # NOTE: Empty lists results in '' (str) regardless of contained type. # Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes # So, fall back to Any -def commonprefix(m: Sequence[AnyPath]) -> Any: ... -def exists(path: AnyPath) -> bool: ... -def lexists(path: AnyPath) -> bool: ... +def commonprefix(m: Sequence[Text]) -> Any: ... +def exists(path: Text) -> bool: ... +def lexists(path: Text) -> bool: ... # These return float if os.stat_float_times() == True, # but int is a subclass of float. -def getatime(filename: AnyPath) -> float: ... -def getmtime(filename: AnyPath) -> float: ... -def getctime(filename: AnyPath) -> float: ... -def getsize(filename: AnyPath) -> int: ... -def isabs(s: AnyPath) -> bool: ... -def isfile(path: AnyPath) -> bool: ... -def isdir(s: AnyPath) -> bool: ... -def islink(path: AnyPath) -> bool: ... -def ismount(path: AnyPath) -> bool: ... +def getatime(filename: Text) -> float: ... +def getmtime(filename: Text) -> float: ... +def getctime(filename: Text) -> float: ... +def getsize(filename: Text) -> int: ... +def isabs(s: Text) -> bool: ... +def isfile(path: Text) -> bool: ... +def isdir(s: Text) -> bool: ... +def islink(path: Text) -> bool: ... +def ismount(path: Text) -> bool: ... # Make sure signatures are disjunct, and allow combinations of bytes and unicode. # (Since Python 2 allows that, too) @@ -61,18 +60,18 @@ def ismount(path: AnyPath) -> bool: ... @overload def join(__p1: bytes, *p: bytes) -> bytes: ... @overload -def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: AnyPath) -> Text: ... +def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: Text) -> Text: ... @overload -def join(__p1: bytes, __p2: bytes, __p3: Text, *p: AnyPath) -> Text: ... +def join(__p1: bytes, __p2: bytes, __p3: Text, *p: Text) -> Text: ... @overload -def join(__p1: bytes, __p2: Text, *p: AnyPath) -> Text: ... +def join(__p1: bytes, __p2: Text, *p: Text) -> Text: ... @overload -def join(__p1: Text, *p: AnyPath) -> Text: ... +def join(__p1: Text, *p: Text) -> Text: ... @overload -def relpath(path: BytesPath, start: Optional[BytesPath] = ...) -> bytes: ... +def relpath(path: str, start: Optional[str] = ...) -> str: ... @overload -def relpath(path: StrPath, start: Optional[StrPath] = ...) -> Text: ... -def samefile(f1: AnyPath, f2: AnyPath) -> bool: ... +def relpath(path: Text, start: Optional[Text] = ...) -> Text: ... +def samefile(f1: Text, f2: Text) -> bool: ... def sameopenfile(fp1: int, fp2: int) -> bool: ... def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... def split(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... diff --git a/stdlib/@python2/os2emxpath.pyi b/stdlib/@python2/os2emxpath.pyi index f09642860..07bd9653e 100644 --- a/stdlib/@python2/os2emxpath.pyi +++ b/stdlib/@python2/os2emxpath.pyi @@ -1,6 +1,5 @@ import os import sys -from _typeshed import AnyPath, BytesPath, StrPath from genericpath import exists as exists from typing import Any, AnyStr, Callable, List, Optional, Sequence, Text, Tuple, TypeVar, overload @@ -39,20 +38,20 @@ else: # NOTE: Empty lists results in '' (str) regardless of contained type. # Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes # So, fall back to Any -def commonprefix(m: Sequence[AnyPath]) -> Any: ... -def lexists(path: AnyPath) -> bool: ... +def commonprefix(m: Sequence[Text]) -> Any: ... +def lexists(path: Text) -> bool: ... # These return float if os.stat_float_times() == True, # but int is a subclass of float. -def getatime(filename: AnyPath) -> float: ... -def getmtime(filename: AnyPath) -> float: ... -def getctime(filename: AnyPath) -> float: ... -def getsize(filename: AnyPath) -> int: ... -def isabs(s: AnyPath) -> bool: ... -def isfile(path: AnyPath) -> bool: ... -def isdir(s: AnyPath) -> bool: ... -def islink(path: AnyPath) -> bool: ... -def ismount(path: AnyPath) -> bool: ... +def getatime(filename: Text) -> float: ... +def getmtime(filename: Text) -> float: ... +def getctime(filename: Text) -> float: ... +def getsize(filename: Text) -> int: ... +def isabs(s: Text) -> bool: ... +def isfile(path: Text) -> bool: ... +def isdir(s: Text) -> bool: ... +def islink(path: Text) -> bool: ... +def ismount(path: Text) -> bool: ... # Make sure signatures are disjunct, and allow combinations of bytes and unicode. # (Since Python 2 allows that, too) @@ -61,18 +60,18 @@ def ismount(path: AnyPath) -> bool: ... @overload def join(__p1: bytes, *p: bytes) -> bytes: ... @overload -def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: AnyPath) -> Text: ... +def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: Text) -> Text: ... @overload -def join(__p1: bytes, __p2: bytes, __p3: Text, *p: AnyPath) -> Text: ... +def join(__p1: bytes, __p2: bytes, __p3: Text, *p: Text) -> Text: ... @overload -def join(__p1: bytes, __p2: Text, *p: AnyPath) -> Text: ... +def join(__p1: bytes, __p2: Text, *p: Text) -> Text: ... @overload -def join(__p1: Text, *p: AnyPath) -> Text: ... +def join(__p1: Text, *p: Text) -> Text: ... @overload -def relpath(path: BytesPath, start: Optional[BytesPath] = ...) -> bytes: ... +def relpath(path: str, start: Optional[str] = ...) -> str: ... @overload -def relpath(path: StrPath, start: Optional[StrPath] = ...) -> Text: ... -def samefile(f1: AnyPath, f2: AnyPath) -> bool: ... +def relpath(path: Text, start: Optional[Text] = ...) -> Text: ... +def samefile(f1: Text, f2: Text) -> bool: ... def sameopenfile(fp1: int, fp2: int) -> bool: ... def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... def split(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... diff --git a/stdlib/@python2/parser.pyi b/stdlib/@python2/parser.pyi index 799f25cf6..ff8bf039e 100644 --- a/stdlib/@python2/parser.pyi +++ b/stdlib/@python2/parser.pyi @@ -1,4 +1,3 @@ -from _typeshed import AnyPath from types import CodeType from typing import Any, List, Sequence, Text, Tuple @@ -8,14 +7,14 @@ def sequence2st(sequence: Sequence[Any]) -> STType: ... def tuple2st(sequence: Sequence[Any]) -> STType: ... def st2list(st: STType, line_info: bool = ..., col_info: bool = ...) -> List[Any]: ... def st2tuple(st: STType, line_info: bool = ..., col_info: bool = ...) -> Tuple[Any]: ... -def compilest(st: STType, filename: AnyPath = ...) -> CodeType: ... +def compilest(st: STType, filename: Text = ...) -> CodeType: ... def isexpr(st: STType) -> bool: ... def issuite(st: STType) -> bool: ... class ParserError(Exception): ... class STType: - def compile(self, filename: AnyPath = ...) -> CodeType: ... + def compile(self, filename: Text = ...) -> CodeType: ... def isexpr(self) -> bool: ... def issuite(self) -> bool: ... def tolist(self, line_info: bool = ..., col_info: bool = ...) -> List[Any]: ... diff --git a/stdlib/@python2/posixpath.pyi b/stdlib/@python2/posixpath.pyi index f09642860..07bd9653e 100644 --- a/stdlib/@python2/posixpath.pyi +++ b/stdlib/@python2/posixpath.pyi @@ -1,6 +1,5 @@ import os import sys -from _typeshed import AnyPath, BytesPath, StrPath from genericpath import exists as exists from typing import Any, AnyStr, Callable, List, Optional, Sequence, Text, Tuple, TypeVar, overload @@ -39,20 +38,20 @@ else: # NOTE: Empty lists results in '' (str) regardless of contained type. # Also, in Python 2 mixed sequences of Text and bytes results in either Text or bytes # So, fall back to Any -def commonprefix(m: Sequence[AnyPath]) -> Any: ... -def lexists(path: AnyPath) -> bool: ... +def commonprefix(m: Sequence[Text]) -> Any: ... +def lexists(path: Text) -> bool: ... # These return float if os.stat_float_times() == True, # but int is a subclass of float. -def getatime(filename: AnyPath) -> float: ... -def getmtime(filename: AnyPath) -> float: ... -def getctime(filename: AnyPath) -> float: ... -def getsize(filename: AnyPath) -> int: ... -def isabs(s: AnyPath) -> bool: ... -def isfile(path: AnyPath) -> bool: ... -def isdir(s: AnyPath) -> bool: ... -def islink(path: AnyPath) -> bool: ... -def ismount(path: AnyPath) -> bool: ... +def getatime(filename: Text) -> float: ... +def getmtime(filename: Text) -> float: ... +def getctime(filename: Text) -> float: ... +def getsize(filename: Text) -> int: ... +def isabs(s: Text) -> bool: ... +def isfile(path: Text) -> bool: ... +def isdir(s: Text) -> bool: ... +def islink(path: Text) -> bool: ... +def ismount(path: Text) -> bool: ... # Make sure signatures are disjunct, and allow combinations of bytes and unicode. # (Since Python 2 allows that, too) @@ -61,18 +60,18 @@ def ismount(path: AnyPath) -> bool: ... @overload def join(__p1: bytes, *p: bytes) -> bytes: ... @overload -def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: AnyPath) -> Text: ... +def join(__p1: bytes, __p2: bytes, __p3: bytes, __p4: Text, *p: Text) -> Text: ... @overload -def join(__p1: bytes, __p2: bytes, __p3: Text, *p: AnyPath) -> Text: ... +def join(__p1: bytes, __p2: bytes, __p3: Text, *p: Text) -> Text: ... @overload -def join(__p1: bytes, __p2: Text, *p: AnyPath) -> Text: ... +def join(__p1: bytes, __p2: Text, *p: Text) -> Text: ... @overload -def join(__p1: Text, *p: AnyPath) -> Text: ... +def join(__p1: Text, *p: Text) -> Text: ... @overload -def relpath(path: BytesPath, start: Optional[BytesPath] = ...) -> bytes: ... +def relpath(path: str, start: Optional[str] = ...) -> str: ... @overload -def relpath(path: StrPath, start: Optional[StrPath] = ...) -> Text: ... -def samefile(f1: AnyPath, f2: AnyPath) -> bool: ... +def relpath(path: Text, start: Optional[Text] = ...) -> Text: ... +def samefile(f1: Text, f2: Text) -> bool: ... def sameopenfile(fp1: int, fp2: int) -> bool: ... def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... def split(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... diff --git a/stdlib/@python2/profile.pyi b/stdlib/@python2/profile.pyi index cc769b604..e799c6b36 100644 --- a/stdlib/@python2/profile.pyi +++ b/stdlib/@python2/profile.pyi @@ -1,5 +1,4 @@ -from _typeshed import AnyPath -from typing import Any, Callable, Dict, Optional, Tuple, TypeVar, Union +from typing import Any, Callable, Dict, Optional, Text, Tuple, TypeVar, Union def run(statement: str, filename: Optional[str] = ..., sort: Union[str, int] = ...) -> None: ... def runctx( @@ -18,7 +17,7 @@ class Profile: def simulate_call(self, name: str) -> None: ... def simulate_cmd_complete(self) -> None: ... def print_stats(self, sort: Union[str, int] = ...) -> None: ... - def dump_stats(self, file: AnyPath) -> None: ... + def dump_stats(self, file: Text) -> None: ... def create_stats(self) -> None: ... def snapshot_stats(self) -> None: ... def run(self: _SelfT, cmd: str) -> _SelfT: ... diff --git a/stdlib/@python2/pstats.pyi b/stdlib/@python2/pstats.pyi index ee5c0dd1c..d1404dc7c 100644 --- a/stdlib/@python2/pstats.pyi +++ b/stdlib/@python2/pstats.pyi @@ -1,4 +1,3 @@ -from _typeshed import AnyPath from cProfile import Profile as _cProfile from profile import Profile from typing import IO, Any, Dict, Iterable, List, Optional, Text, Tuple, TypeVar, Union, overload @@ -18,7 +17,7 @@ class Stats: def load_stats(self, arg: Union[None, str, Text, Profile, _cProfile]) -> None: ... def get_top_level_stats(self) -> None: ... def add(self: _T, *arg_list: Union[None, str, Text, Profile, _cProfile, _T]) -> _T: ... - def dump_stats(self, filename: AnyPath) -> None: ... + def dump_stats(self, filename: Text) -> None: ... def get_sort_arg_defs(self) -> Dict[str, Tuple[Tuple[Tuple[int, int], ...], str]]: ... @overload def sort_stats(self: _T, field: int) -> _T: ... diff --git a/stdlib/@python2/readline.pyi b/stdlib/@python2/readline.pyi index b0d2cac32..579308f75 100644 --- a/stdlib/@python2/readline.pyi +++ b/stdlib/@python2/readline.pyi @@ -1,16 +1,15 @@ -from _typeshed import AnyPath -from typing import Callable, Optional, Sequence +from typing import Callable, Optional, Sequence, Text _CompleterT = Optional[Callable[[str, int], Optional[str]]] _CompDispT = Optional[Callable[[str, Sequence[str], int], None]] def parse_and_bind(__string: str) -> None: ... -def read_init_file(__filename: Optional[AnyPath] = ...) -> None: ... +def read_init_file(__filename: Optional[Text] = ...) -> None: ... def get_line_buffer() -> str: ... def insert_text(__string: str) -> None: ... def redisplay() -> None: ... -def read_history_file(__filename: Optional[AnyPath] = ...) -> None: ... -def write_history_file(__filename: Optional[AnyPath] = ...) -> None: ... +def read_history_file(__filename: Optional[Text] = ...) -> None: ... +def write_history_file(__filename: Optional[Text] = ...) -> None: ... def get_history_length() -> int: ... def set_history_length(__length: int) -> None: ... def clear_history() -> None: ... diff --git a/stdlib/@python2/shutil.pyi b/stdlib/@python2/shutil.pyi index a1c9cd23b..ff4467ffc 100644 --- a/stdlib/@python2/shutil.pyi +++ b/stdlib/@python2/shutil.pyi @@ -1,5 +1,5 @@ -from _typeshed import StrPath, SupportsRead, SupportsWrite -from typing import Any, AnyStr, Callable, Iterable, List, Optional, Sequence, Set, Tuple, Type, TypeVar, Union +from _typeshed import SupportsRead, SupportsWrite +from typing import Any, AnyStr, Callable, Iterable, List, Optional, Sequence, Set, Text, Tuple, Type, TypeVar, Union _AnyStr = TypeVar("_AnyStr", str, unicode) _AnyPath = TypeVar("_AnyPath", str, unicode) @@ -10,25 +10,25 @@ class SpecialFileError(EnvironmentError): ... class ExecError(EnvironmentError): ... def copyfileobj(fsrc: SupportsRead[AnyStr], fdst: SupportsWrite[AnyStr], length: int = ...) -> None: ... -def copyfile(src: StrPath, dst: StrPath) -> None: ... -def copymode(src: StrPath, dst: StrPath) -> None: ... -def copystat(src: StrPath, dst: StrPath) -> None: ... -def copy(src: StrPath, dst: StrPath) -> _PathReturn: ... -def copy2(src: StrPath, dst: StrPath) -> _PathReturn: ... -def ignore_patterns(*patterns: StrPath) -> Callable[[Any, List[_AnyStr]], Set[_AnyStr]]: ... +def copyfile(src: Text, dst: Text) -> None: ... +def copymode(src: Text, dst: Text) -> None: ... +def copystat(src: Text, dst: Text) -> None: ... +def copy(src: Text, dst: Text) -> _PathReturn: ... +def copy2(src: Text, dst: Text) -> _PathReturn: ... +def ignore_patterns(*patterns: Text) -> Callable[[Any, List[_AnyStr]], Set[_AnyStr]]: ... def copytree( src: AnyStr, dst: AnyStr, symlinks: bool = ..., ignore: Union[None, Callable[[AnyStr, List[AnyStr]], Iterable[AnyStr]]] = ... ) -> _PathReturn: ... def rmtree(path: _AnyPath, ignore_errors: bool = ..., onerror: Optional[Callable[[Any, _AnyPath, Any], Any]] = ...) -> None: ... -_CopyFn = Union[Callable[[str, str], None], Callable[[StrPath, StrPath], None]] +_CopyFn = Union[Callable[[str, str], None], Callable[[Text, Text], None]] -def move(src: StrPath, dst: StrPath) -> _PathReturn: ... +def move(src: Text, dst: Text) -> _PathReturn: ... def make_archive( base_name: _AnyStr, format: str, - root_dir: Optional[StrPath] = ..., - base_dir: Optional[StrPath] = ..., + root_dir: Optional[Text] = ..., + base_dir: Optional[Text] = ..., verbose: bool = ..., dry_run: bool = ..., owner: Optional[str] = ..., diff --git a/stdlib/@python2/sndhdr.pyi b/stdlib/@python2/sndhdr.pyi index 5163f8630..a5ae485c2 100644 --- a/stdlib/@python2/sndhdr.pyi +++ b/stdlib/@python2/sndhdr.pyi @@ -1,7 +1,6 @@ -from _typeshed import AnyPath -from typing import Optional, Tuple, Union +from typing import Optional, Text, Tuple, Union _SndHeaders = Tuple[str, int, int, int, Union[int, str]] -def what(filename: AnyPath) -> Optional[_SndHeaders]: ... -def whathdr(filename: AnyPath) -> Optional[_SndHeaders]: ... +def what(filename: Text) -> Optional[_SndHeaders]: ... +def whathdr(filename: Text) -> Optional[_SndHeaders]: ... diff --git a/stdlib/@python2/tabnanny.pyi b/stdlib/@python2/tabnanny.pyi index 7784c9fc8..95873761e 100644 --- a/stdlib/@python2/tabnanny.pyi +++ b/stdlib/@python2/tabnanny.pyi @@ -1,5 +1,4 @@ -from _typeshed import AnyPath -from typing import Iterable, Tuple +from typing import Iterable, Text, Tuple verbose: int filename_only: int @@ -10,5 +9,5 @@ class NannyNag(Exception): def get_msg(self) -> str: ... def get_line(self) -> str: ... -def check(file: AnyPath) -> None: ... +def check(file: Text) -> None: ... def process_tokens(tokens: Iterable[Tuple[int, str, Tuple[int, int], Tuple[int, int], str]]) -> None: ... diff --git a/stdlib/@python2/tarfile.pyi b/stdlib/@python2/tarfile.pyi index 01ae3cdf5..169d7d2c8 100644 --- a/stdlib/@python2/tarfile.pyi +++ b/stdlib/@python2/tarfile.pyi @@ -1,7 +1,6 @@ import io -from _typeshed import AnyPath from types import TracebackType -from typing import IO, Callable, Dict, Iterable, Iterator, List, Mapping, Optional, Tuple, Type, Union +from typing import IO, Callable, Dict, Iterable, Iterator, List, Mapping, Optional, Text, Tuple, Type, Union # tar constants NUL: bytes @@ -51,7 +50,7 @@ TAR_PLAIN: int TAR_GZIPPED: int def open( - name: Optional[AnyPath] = ..., + name: Optional[Text] = ..., mode: str = ..., fileobj: Optional[IO[bytes]] = ..., bufsize: int = ..., @@ -73,7 +72,7 @@ class ExFileObject(io.BufferedReader): class TarFile(Iterable[TarInfo]): OPEN_METH: Mapping[str, str] - name: Optional[AnyPath] + name: Optional[Text] mode: str fileobj: Optional[IO[bytes]] format: Optional[int] @@ -90,7 +89,7 @@ class TarFile(Iterable[TarInfo]): posix: bool def __init__( self, - name: Optional[AnyPath] = ..., + name: Optional[Text] = ..., mode: str = ..., fileobj: Optional[IO[bytes]] = ..., format: Optional[int] = ..., @@ -112,7 +111,7 @@ class TarFile(Iterable[TarInfo]): @classmethod def open( cls, - name: Optional[AnyPath] = ..., + name: Optional[Text] = ..., mode: str = ..., fileobj: Optional[IO[bytes]] = ..., bufsize: int = ..., @@ -130,7 +129,7 @@ class TarFile(Iterable[TarInfo]): @classmethod def taropen( cls, - name: Optional[AnyPath], + name: Optional[Text], mode: str = ..., fileobj: Optional[IO[bytes]] = ..., *, @@ -147,7 +146,7 @@ class TarFile(Iterable[TarInfo]): @classmethod def gzopen( cls, - name: Optional[AnyPath], + name: Optional[Text], mode: str = ..., fileobj: Optional[IO[bytes]] = ..., compresslevel: int = ..., @@ -164,7 +163,7 @@ class TarFile(Iterable[TarInfo]): @classmethod def bz2open( cls, - name: Optional[AnyPath], + name: Optional[Text], mode: str = ..., fileobj: Optional[IO[bytes]] = ..., compresslevel: int = ..., @@ -181,7 +180,7 @@ class TarFile(Iterable[TarInfo]): @classmethod def xzopen( cls, - name: Optional[AnyPath], + name: Optional[Text], mode: str = ..., fileobj: Optional[IO[bytes]] = ..., preset: Optional[int] = ..., @@ -200,18 +199,18 @@ class TarFile(Iterable[TarInfo]): def getnames(self) -> List[str]: ... def list(self, verbose: bool = ...) -> None: ... def next(self) -> Optional[TarInfo]: ... - def extractall(self, path: AnyPath = ..., members: Optional[Iterable[TarInfo]] = ...) -> None: ... - def extract(self, member: Union[str, TarInfo], path: AnyPath = ...) -> None: ... + def extractall(self, path: Text = ..., members: Optional[Iterable[TarInfo]] = ...) -> None: ... + def extract(self, member: Union[str, TarInfo], path: Text = ...) -> None: ... def extractfile(self, member: Union[str, TarInfo]) -> Optional[IO[bytes]]: ... - def makedir(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - def makefile(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - def makeunknown(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - def makefifo(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - def makedev(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - def makelink(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - def chown(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - def chmod(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - def utime(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented + def makedir(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented + def makefile(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented + def makeunknown(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented + def makefifo(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented + def makedev(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented + def makelink(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented + def chown(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented + def chmod(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented + def utime(self, tarinfo: TarInfo, targetpath: Text) -> None: ... # undocumented def add( self, name: str, @@ -226,7 +225,7 @@ class TarFile(Iterable[TarInfo]): ) -> TarInfo: ... def close(self) -> None: ... -def is_tarfile(name: AnyPath) -> bool: ... +def is_tarfile(name: Text) -> bool: ... def filemode(mode: int) -> str: ... # undocumented class TarFileCompat: diff --git a/stdlib/@python2/xml/etree/ElementTree.pyi b/stdlib/@python2/xml/etree/ElementTree.pyi index 8292c6e7d..f7527fa5d 100644 --- a/stdlib/@python2/xml/etree/ElementTree.pyi +++ b/stdlib/@python2/xml/etree/ElementTree.pyi @@ -1,4 +1,4 @@ -from _typeshed import AnyPath, FileDescriptor +from _typeshed import FileDescriptor from typing import ( IO, Any, @@ -50,7 +50,7 @@ _str_argument_type = Union[str, Text] # _fixtext function in the source). Client code knows best: _str_result_type = Any -_file_or_filename = Union[AnyPath, FileDescriptor, IO[Any]] +_file_or_filename = Union[Text, FileDescriptor, IO[Any]] class Element(MutableSequence[Element]): tag: _str_result_type diff --git a/stdlib/_typeshed/__init__.pyi b/stdlib/_typeshed/__init__.pyi index b3f531daf..3dce9de09 100644 --- a/stdlib/_typeshed/__init__.pyi +++ b/stdlib/_typeshed/__init__.pyi @@ -58,11 +58,11 @@ class SupportsItemAccess(SupportsGetItem[_KT_contra, _VT], Protocol[_KT_contra, def __setitem__(self, __k: _KT_contra, __v: _VT) -> None: ... def __delitem__(self, __v: _KT_contra) -> None: ... -# StrPath and AnyPath can be used in places where a -# path can be used instead of a string, starting with Python 3.6. +# These aliases are simple strings in Python 2. StrPath = Union[str, PathLike[str]] BytesPath = Union[bytes, PathLike[bytes]] -AnyPath = Union[str, bytes, PathLike[str], PathLike[bytes]] +StrOrBytesPath = Union[str, bytes, PathLike[str], PathLike[bytes]] +AnyPath = StrOrBytesPath # obsolete, will be removed soon OpenTextModeUpdating = Literal[ "r+", diff --git a/stdlib/asyncio/base_tasks.pyi b/stdlib/asyncio/base_tasks.pyi index fbe0a03e8..b336ae488 100644 --- a/stdlib/asyncio/base_tasks.pyi +++ b/stdlib/asyncio/base_tasks.pyi @@ -1,4 +1,4 @@ -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from types import FrameType from typing import Any, List, Optional @@ -6,4 +6,4 @@ from . import tasks def _task_repr_info(task: tasks.Task[Any]) -> List[str]: ... # undocumented def _task_get_stack(task: tasks.Task[Any], limit: Optional[int]) -> List[FrameType]: ... # undocumented -def _task_print_stack(task: tasks.Task[Any], limit: Optional[int], file: AnyPath) -> None: ... # undocumented +def _task_print_stack(task: tasks.Task[Any], limit: Optional[int], file: StrOrBytesPath) -> None: ... # undocumented diff --git a/stdlib/asyncio/subprocess.pyi b/stdlib/asyncio/subprocess.pyi index d443625db..9d28d9e2b 100644 --- a/stdlib/asyncio/subprocess.pyi +++ b/stdlib/asyncio/subprocess.pyi @@ -1,12 +1,12 @@ import subprocess import sys -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from asyncio import events, protocols, streams, transports from typing import IO, Any, Callable, Optional, Tuple, Union from typing_extensions import Literal if sys.version_info >= (3, 8): - _ExecArg = AnyPath + _ExecArg = StrOrBytesPath else: _ExecArg = Union[str, bytes] @@ -56,10 +56,10 @@ if sys.version_info >= (3, 10): errors: None = ..., text: Literal[False, None] = ..., # These parameters are taken by subprocess.Popen, which this ultimately delegates to - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[subprocess._ENV] = ..., startupinfo: Optional[Any] = ..., creationflags: int = ..., @@ -82,10 +82,10 @@ if sys.version_info >= (3, 10): errors: None = ..., # These parameters are taken by subprocess.Popen, which this ultimately delegates to text: Optional[bool] = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[subprocess._ENV] = ..., startupinfo: Optional[Any] = ..., creationflags: int = ..., @@ -111,10 +111,10 @@ else: errors: None = ..., text: Literal[False, None] = ..., # These parameters are taken by subprocess.Popen, which this ultimately delegates to - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[subprocess._ENV] = ..., startupinfo: Optional[Any] = ..., creationflags: int = ..., @@ -138,10 +138,10 @@ else: errors: None = ..., # These parameters are taken by subprocess.Popen, which this ultimately delegates to text: Optional[bool] = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[subprocess._ENV] = ..., startupinfo: Optional[Any] = ..., creationflags: int = ..., diff --git a/stdlib/builtins.pyi b/stdlib/builtins.pyi index 69da37190..847810586 100644 --- a/stdlib/builtins.pyi +++ b/stdlib/builtins.pyi @@ -1,13 +1,13 @@ import sys import types from _typeshed import ( - AnyPath, OpenBinaryMode, OpenBinaryModeReading, OpenBinaryModeUpdating, OpenBinaryModeWriting, OpenTextMode, ReadableBuffer, + StrOrBytesPath, SupportsDivMod, SupportsKeysAndGetItem, SupportsLessThan, @@ -1115,7 +1115,7 @@ def next(__i: Iterator[_T]) -> _T: ... def next(__i: Iterator[_T], default: _VT) -> Union[_T, _VT]: ... def oct(__number: Union[int, SupportsIndex]) -> str: ... -_OpenFile = Union[AnyPath, int] +_OpenFile = Union[StrOrBytesPath, int] _Opener = Callable[[str, int], int] # Text mode: always returns a TextIOWrapper diff --git a/stdlib/bz2.pyi b/stdlib/bz2.pyi index eb07a8ea9..390024a04 100644 --- a/stdlib/bz2.pyi +++ b/stdlib/bz2.pyi @@ -1,10 +1,10 @@ import io import sys -from _typeshed import AnyPath, ReadableBuffer, WriteableBuffer +from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer from typing import IO, Any, Iterable, List, Optional, TextIO, TypeVar, Union, overload from typing_extensions import Literal, SupportsIndex -_PathOrFile = Union[AnyPath, IO[bytes]] +_PathOrFile = Union[StrOrBytesPath, IO[bytes]] _T = TypeVar("_T") def compress(data: bytes, compresslevel: int = ...) -> bytes: ... @@ -24,7 +24,7 @@ def open( ) -> BZ2File: ... @overload def open( - filename: AnyPath, + filename: StrOrBytesPath, mode: _OpenTextMode, compresslevel: int = ..., encoding: Optional[str] = ..., diff --git a/stdlib/cProfile.pyi b/stdlib/cProfile.pyi index 638a2a79f..6648ed5b9 100644 --- a/stdlib/cProfile.pyi +++ b/stdlib/cProfile.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from types import CodeType from typing import Any, Callable, Dict, Optional, Tuple, TypeVar, Union @@ -20,7 +20,7 @@ class Profile: def enable(self) -> None: ... def disable(self) -> None: ... def print_stats(self, sort: Union[str, int] = ...) -> None: ... - def dump_stats(self, file: AnyPath) -> None: ... + def dump_stats(self, file: StrOrBytesPath) -> None: ... def create_stats(self) -> None: ... def snapshot_stats(self) -> None: ... def run(self: _SelfT, cmd: str) -> _SelfT: ... diff --git a/stdlib/cgitb.pyi b/stdlib/cgitb.pyi index 7603ecd9a..b8db1d809 100644 --- a/stdlib/cgitb.pyi +++ b/stdlib/cgitb.pyi @@ -1,4 +1,4 @@ -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from types import FrameType, TracebackType from typing import IO, Any, Callable, Dict, List, Optional, Tuple, Type @@ -19,7 +19,7 @@ class Hook: # undocumented def __init__( self, display: int = ..., - logdir: Optional[AnyPath] = ..., + logdir: Optional[StrOrBytesPath] = ..., context: int = ..., file: Optional[IO[str]] = ..., format: str = ..., @@ -30,4 +30,4 @@ class Hook: # undocumented def handle(self, info: Optional[_ExcInfo] = ...) -> None: ... def handler(info: Optional[_ExcInfo] = ...) -> None: ... -def enable(display: int = ..., logdir: Optional[AnyPath] = ..., context: int = ..., format: str = ...) -> None: ... +def enable(display: int = ..., logdir: Optional[StrOrBytesPath] = ..., context: int = ..., format: str = ...) -> None: ... diff --git a/stdlib/configparser.pyi b/stdlib/configparser.pyi index f4a4e889c..46e5201a1 100644 --- a/stdlib/configparser.pyi +++ b/stdlib/configparser.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import AnyPath, StrPath, SupportsWrite +from _typeshed import StrOrBytesPath, StrPath, SupportsWrite from typing import ( AbstractSet, Any, @@ -30,7 +30,7 @@ _converters = Dict[str, _converter] _T = TypeVar("_T") if sys.version_info >= (3, 7): - _Path = AnyPath + _Path = StrOrBytesPath else: _Path = StrPath diff --git a/stdlib/distutils/dist.pyi b/stdlib/distutils/dist.pyi index d3acdafbd..8655371ad 100644 --- a/stdlib/distutils/dist.pyi +++ b/stdlib/distutils/dist.pyi @@ -1,9 +1,9 @@ -from _typeshed import AnyPath, SupportsWrite +from _typeshed import StrOrBytesPath, SupportsWrite from distutils.cmd import Command from typing import IO, Any, Dict, Iterable, List, Mapping, Optional, Tuple, Type, Union class DistributionMetadata: - def __init__(self, path: Optional[Union[int, AnyPath]] = ...) -> None: ... + def __init__(self, path: Optional[Union[int, StrOrBytesPath]] = ...) -> None: ... name: Optional[str] version: Optional[str] author: Optional[str] diff --git a/stdlib/filecmp.pyi b/stdlib/filecmp.pyi index 4dd763e82..b3f20eb6b 100644 --- a/stdlib/filecmp.pyi +++ b/stdlib/filecmp.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from os import PathLike from typing import Any, AnyStr, Callable, Dict, Generic, Iterable, List, Optional, Sequence, Tuple, Union @@ -8,7 +8,7 @@ if sys.version_info >= (3, 9): DEFAULT_IGNORES: List[str] -def cmp(f1: AnyPath, f2: AnyPath, shallow: Union[int, bool] = ...) -> bool: ... +def cmp(f1: StrOrBytesPath, f2: StrOrBytesPath, shallow: Union[int, bool] = ...) -> bool: ... def cmpfiles( a: Union[AnyStr, PathLike[AnyStr]], b: Union[AnyStr, PathLike[AnyStr]], diff --git a/stdlib/fileinput.pyi b/stdlib/fileinput.pyi index dc7e01b87..ed07ebecd 100644 --- a/stdlib/fileinput.pyi +++ b/stdlib/fileinput.pyi @@ -1,25 +1,25 @@ import sys -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from typing import IO, Any, AnyStr, Callable, Generic, Iterable, Iterator, Optional, Union if sys.version_info >= (3, 8): def input( - files: Union[AnyPath, Iterable[AnyPath], None] = ..., + files: Union[StrOrBytesPath, Iterable[StrOrBytesPath], None] = ..., inplace: bool = ..., backup: str = ..., *, mode: str = ..., - openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., + openhook: Callable[[StrOrBytesPath, str], IO[AnyStr]] = ..., ) -> FileInput[AnyStr]: ... else: def input( - files: Union[AnyPath, Iterable[AnyPath], None] = ..., + files: Union[StrOrBytesPath, Iterable[StrOrBytesPath], None] = ..., inplace: bool = ..., backup: str = ..., bufsize: int = ..., mode: str = ..., - openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., + openhook: Callable[[StrOrBytesPath, str], IO[AnyStr]] = ..., ) -> FileInput[AnyStr]: ... def close() -> None: ... @@ -35,22 +35,22 @@ class FileInput(Iterable[AnyStr], Generic[AnyStr]): if sys.version_info >= (3, 8): def __init__( self, - files: Union[None, AnyPath, Iterable[AnyPath]] = ..., + files: Union[None, StrOrBytesPath, Iterable[StrOrBytesPath]] = ..., inplace: bool = ..., backup: str = ..., *, mode: str = ..., - openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., + openhook: Callable[[StrOrBytesPath, str], IO[AnyStr]] = ..., ) -> None: ... else: def __init__( self, - files: Union[None, AnyPath, Iterable[AnyPath]] = ..., + files: Union[None, StrOrBytesPath, Iterable[StrOrBytesPath]] = ..., inplace: bool = ..., backup: str = ..., bufsize: int = ..., mode: str = ..., - openhook: Callable[[AnyPath, str], IO[AnyStr]] = ..., + openhook: Callable[[StrOrBytesPath, str], IO[AnyStr]] = ..., ) -> None: ... def __del__(self) -> None: ... def close(self) -> None: ... @@ -68,5 +68,5 @@ class FileInput(Iterable[AnyStr], Generic[AnyStr]): def isfirstline(self) -> bool: ... def isstdin(self) -> bool: ... -def hook_compressed(filename: AnyPath, mode: str) -> IO[Any]: ... -def hook_encoded(encoding: str, errors: Optional[str] = ...) -> Callable[[AnyPath, str], IO[Any]]: ... +def hook_compressed(filename: StrOrBytesPath, mode: str) -> IO[Any]: ... +def hook_encoded(encoding: str, errors: Optional[str] = ...) -> Callable[[StrOrBytesPath, str], IO[Any]]: ... diff --git a/stdlib/genericpath.pyi b/stdlib/genericpath.pyi index ff5f37a46..7bd6a1ebd 100644 --- a/stdlib/genericpath.pyi +++ b/stdlib/genericpath.pyi @@ -1,5 +1,5 @@ import os -from _typeshed import AnyPath, BytesPath, StrPath, SupportsLessThanT +from _typeshed import BytesPath, StrOrBytesPath, StrPath, SupportsLessThanT from typing import List, Sequence, Tuple, Union, overload from typing_extensions import Literal @@ -14,16 +14,16 @@ def commonprefix(m: Sequence[BytesPath]) -> Union[bytes, Literal[""]]: ... def commonprefix(m: Sequence[List[SupportsLessThanT]]) -> Sequence[SupportsLessThanT]: ... @overload def commonprefix(m: Sequence[Tuple[SupportsLessThanT, ...]]) -> Sequence[SupportsLessThanT]: ... -def exists(path: AnyPath) -> bool: ... -def getsize(filename: AnyPath) -> int: ... -def isfile(path: AnyPath) -> bool: ... -def isdir(s: AnyPath) -> bool: ... +def exists(path: StrOrBytesPath) -> bool: ... +def getsize(filename: StrOrBytesPath) -> int: ... +def isfile(path: StrOrBytesPath) -> bool: ... +def isdir(s: StrOrBytesPath) -> bool: ... # These return float if os.stat_float_times() == True, # but int is a subclass of float. -def getatime(filename: AnyPath) -> float: ... -def getmtime(filename: AnyPath) -> float: ... -def getctime(filename: AnyPath) -> float: ... -def samefile(f1: AnyPath, f2: AnyPath) -> bool: ... +def getatime(filename: StrOrBytesPath) -> float: ... +def getmtime(filename: StrOrBytesPath) -> float: ... +def getctime(filename: StrOrBytesPath) -> float: ... +def samefile(f1: StrOrBytesPath, f2: StrOrBytesPath) -> bool: ... def sameopenfile(fp1: int, fp2: int) -> bool: ... def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ... diff --git a/stdlib/glob.pyi b/stdlib/glob.pyi index 42269e95d..33582d15f 100644 --- a/stdlib/glob.pyi +++ b/stdlib/glob.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from typing import AnyStr, Iterator, List, Optional, Union def glob0(dirname: AnyStr, pattern: AnyStr) -> List[AnyStr]: ... @@ -7,10 +7,10 @@ def glob1(dirname: AnyStr, pattern: AnyStr) -> List[AnyStr]: ... if sys.version_info >= (3, 10): def glob( - pathname: AnyStr, *, root_dir: Optional[AnyPath] = ..., dir_fd: Optional[int] = ..., recursive: bool = ... + pathname: AnyStr, *, root_dir: Optional[StrOrBytesPath] = ..., dir_fd: Optional[int] = ..., recursive: bool = ... ) -> List[AnyStr]: ... def iglob( - pathname: AnyStr, *, root_dir: Optional[AnyPath] = ..., dir_fd: Optional[int] = ..., recursive: bool = ... + pathname: AnyStr, *, root_dir: Optional[StrOrBytesPath] = ..., dir_fd: Optional[int] = ..., recursive: bool = ... ) -> Iterator[AnyStr]: ... else: diff --git a/stdlib/gzip.pyi b/stdlib/gzip.pyi index 8d061e051..efba70703 100644 --- a/stdlib/gzip.pyi +++ b/stdlib/gzip.pyi @@ -1,7 +1,7 @@ import _compression import sys import zlib -from _typeshed import AnyPath, ReadableBuffer +from _typeshed import ReadableBuffer, StrOrBytesPath from io import FileIO from typing import Any, Optional, Protocol, TextIO, Union, overload from typing_extensions import Literal @@ -31,7 +31,7 @@ class _WritableFileobj(Protocol): @overload def open( - filename: Union[AnyPath, _ReadableFileobj], + filename: Union[StrOrBytesPath, _ReadableFileobj], mode: _ReadBinaryMode = ..., compresslevel: int = ..., encoding: None = ..., @@ -40,7 +40,7 @@ def open( ) -> GzipFile: ... @overload def open( - filename: Union[AnyPath, _WritableFileobj], + filename: Union[StrOrBytesPath, _WritableFileobj], mode: _WriteBinaryMode, compresslevel: int = ..., encoding: None = ..., @@ -49,7 +49,7 @@ def open( ) -> GzipFile: ... @overload def open( - filename: AnyPath, + filename: StrOrBytesPath, mode: _OpenTextMode, compresslevel: int = ..., encoding: Optional[str] = ..., @@ -58,7 +58,7 @@ def open( ) -> TextIO: ... @overload def open( - filename: Union[AnyPath, _ReadableFileobj, _WritableFileobj], + filename: Union[StrOrBytesPath, _ReadableFileobj, _WritableFileobj], mode: str, compresslevel: int = ..., encoding: Optional[str] = ..., @@ -86,7 +86,7 @@ class GzipFile(_compression.BaseStream): @overload def __init__( self, - filename: Optional[AnyPath], + filename: Optional[StrOrBytesPath], mode: _ReadBinaryMode, compresslevel: int = ..., fileobj: Optional[_ReadableFileobj] = ..., @@ -104,7 +104,7 @@ class GzipFile(_compression.BaseStream): @overload def __init__( self, - filename: Optional[AnyPath], + filename: Optional[StrOrBytesPath], mode: _WriteBinaryMode, compresslevel: int = ..., fileobj: Optional[_WritableFileobj] = ..., @@ -122,7 +122,7 @@ class GzipFile(_compression.BaseStream): @overload def __init__( self, - filename: Optional[AnyPath] = ..., + filename: Optional[StrOrBytesPath] = ..., mode: Optional[str] = ..., compresslevel: int = ..., fileobj: Union[_ReadableFileobj, _WritableFileobj, None] = ..., diff --git a/stdlib/importlib/abc.pyi b/stdlib/importlib/abc.pyi index 62b391e21..69b03567b 100644 --- a/stdlib/importlib/abc.pyi +++ b/stdlib/importlib/abc.pyi @@ -1,6 +1,6 @@ import sys import types -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from abc import ABCMeta, abstractmethod from importlib.machinery import ModuleSpec from typing import IO, Any, Iterator, Mapping, Optional, Protocol, Sequence, Tuple, Union @@ -73,9 +73,9 @@ class FileLoader(ResourceLoader, ExecutionLoader, metaclass=ABCMeta): if sys.version_info >= (3, 7): class ResourceReader(metaclass=ABCMeta): @abstractmethod - def open_resource(self, resource: AnyPath) -> IO[bytes]: ... + def open_resource(self, resource: StrOrBytesPath) -> IO[bytes]: ... @abstractmethod - def resource_path(self, resource: AnyPath) -> str: ... + def resource_path(self, resource: StrOrBytesPath) -> str: ... @abstractmethod def is_resource(self, name: str) -> bool: ... @abstractmethod diff --git a/stdlib/importlib/util.pyi b/stdlib/importlib/util.pyi index d1c92c579..7dea5a718 100644 --- a/stdlib/importlib/util.pyi +++ b/stdlib/importlib/util.pyi @@ -1,7 +1,7 @@ import importlib.abc import importlib.machinery import types -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from typing import Any, Callable, List, Optional def module_for_loader(fxn: Callable[..., types.ModuleType]) -> Callable[..., types.ModuleType]: ... @@ -20,7 +20,7 @@ def spec_from_loader( ) -> Optional[importlib.machinery.ModuleSpec]: ... def spec_from_file_location( name: str, - location: Optional[AnyPath] = ..., + location: Optional[StrOrBytesPath] = ..., *, loader: Optional[importlib.abc.Loader] = ..., submodule_search_locations: Optional[List[str]] = ..., diff --git a/stdlib/logging/config.pyi b/stdlib/logging/config.pyi index be2f2e685..ed79f48aa 100644 --- a/stdlib/logging/config.pyi +++ b/stdlib/logging/config.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import AnyPath, StrPath +from _typeshed import StrOrBytesPath, StrPath from collections.abc import Callable from configparser import RawConfigParser from threading import Thread @@ -11,7 +11,7 @@ else: from typing_extensions import Literal if sys.version_info >= (3, 7): - _Path = AnyPath + _Path = StrOrBytesPath else: _Path = StrPath diff --git a/stdlib/lzma.pyi b/stdlib/lzma.pyi index 7290a25b3..0228b9d12 100644 --- a/stdlib/lzma.pyi +++ b/stdlib/lzma.pyi @@ -1,12 +1,12 @@ import io -from _typeshed import AnyPath, ReadableBuffer +from _typeshed import ReadableBuffer, StrOrBytesPath from typing import IO, Any, Mapping, Optional, Sequence, TextIO, TypeVar, Union, overload from typing_extensions import Literal _OpenBinaryWritingMode = Literal["w", "wb", "x", "xb", "a", "ab"] _OpenTextWritingMode = Literal["wt", "xt", "at"] -_PathOrFile = Union[AnyPath, IO[bytes]] +_PathOrFile = Union[StrOrBytesPath, IO[bytes]] _FilterChain = Sequence[Mapping[str, Any]] _T = TypeVar("_T") @@ -120,7 +120,7 @@ def open( ) -> LZMAFile: ... @overload def open( - filename: AnyPath, + filename: StrOrBytesPath, mode: Literal["rt"], *, format: Optional[int] = ..., @@ -133,7 +133,7 @@ def open( ) -> TextIO: ... @overload def open( - filename: AnyPath, + filename: StrOrBytesPath, mode: _OpenTextWritingMode, *, format: Optional[int] = ..., diff --git a/stdlib/macpath.pyi b/stdlib/macpath.pyi index 64685d6af..ecb4e9146 100644 --- a/stdlib/macpath.pyi +++ b/stdlib/macpath.pyi @@ -1,4 +1,4 @@ -from _typeshed import AnyPath, BytesPath, StrPath +from _typeshed import BytesPath, StrOrBytesPath, StrPath from genericpath import ( commonprefix as commonprefix, exists as exists, @@ -56,7 +56,7 @@ def normpath(s: AnyStr) -> AnyStr: ... def realpath(path: PathLike[AnyStr]) -> AnyStr: ... @overload def realpath(path: AnyStr) -> AnyStr: ... -def islink(s: AnyPath) -> bool: ... +def islink(s: StrOrBytesPath) -> bool: ... # Mypy complains that the signatures overlap, but things seem to behave correctly anyway. @overload diff --git a/stdlib/mailbox.pyi b/stdlib/mailbox.pyi index 7f3f02314..1abe616fd 100644 --- a/stdlib/mailbox.pyi +++ b/stdlib/mailbox.pyi @@ -1,6 +1,6 @@ import email.message import sys -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from types import TracebackType from typing import ( IO, @@ -43,7 +43,9 @@ class Mailbox(Generic[_MessageT]): _path: Union[bytes, str] # undocumented _factory: Optional[Callable[[IO[Any]], _MessageT]] # undocumented - def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], _MessageT]] = ..., create: bool = ...) -> None: ... + def __init__( + self, path: StrOrBytesPath, factory: Optional[Callable[[IO[Any]], _MessageT]] = ..., create: bool = ... + ) -> None: ... def add(self, message: _MessageData) -> str: ... def remove(self, key: str) -> None: ... def __delitem__(self, key: str) -> None: ... @@ -86,7 +88,7 @@ class Maildir(Mailbox[MaildirMessage]): colon: str def __init__( - self, dirname: AnyPath, factory: Optional[Callable[[IO[Any]], MaildirMessage]] = ..., create: bool = ... + self, dirname: StrOrBytesPath, factory: Optional[Callable[[IO[Any]], MaildirMessage]] = ..., create: bool = ... ) -> None: ... def get_file(self, key: str) -> _ProxyFile[bytes]: ... def list_folders(self) -> List[str]: ... @@ -104,24 +106,32 @@ class _mboxMMDF(_singlefileMailbox[_MessageT]): def get_string(self, key: str, from_: bool = ...) -> str: ... class mbox(_mboxMMDF[mboxMessage]): - def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], mboxMessage]] = ..., create: bool = ...) -> None: ... + def __init__( + self, path: StrOrBytesPath, factory: Optional[Callable[[IO[Any]], mboxMessage]] = ..., create: bool = ... + ) -> None: ... class MMDF(_mboxMMDF[MMDFMessage]): - def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], MMDFMessage]] = ..., create: bool = ...) -> None: ... + def __init__( + self, path: StrOrBytesPath, factory: Optional[Callable[[IO[Any]], MMDFMessage]] = ..., create: bool = ... + ) -> None: ... class MH(Mailbox[MHMessage]): - def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], MHMessage]] = ..., create: bool = ...) -> None: ... + def __init__( + self, path: StrOrBytesPath, factory: Optional[Callable[[IO[Any]], MHMessage]] = ..., create: bool = ... + ) -> None: ... def get_file(self, key: str) -> _ProxyFile[bytes]: ... def list_folders(self) -> List[str]: ... - def get_folder(self, folder: AnyPath) -> MH: ... - def add_folder(self, folder: AnyPath) -> MH: ... - def remove_folder(self, folder: AnyPath) -> None: ... + def get_folder(self, folder: StrOrBytesPath) -> MH: ... + def add_folder(self, folder: StrOrBytesPath) -> MH: ... + def remove_folder(self, folder: StrOrBytesPath) -> None: ... def get_sequences(self) -> Dict[str, List[int]]: ... def set_sequences(self, sequences: Mapping[str, Sequence[int]]) -> None: ... def pack(self) -> None: ... class Babyl(_singlefileMailbox[BabylMessage]): - def __init__(self, path: AnyPath, factory: Optional[Callable[[IO[Any]], BabylMessage]] = ..., create: bool = ...) -> None: ... + def __init__( + self, path: StrOrBytesPath, factory: Optional[Callable[[IO[Any]], BabylMessage]] = ..., create: bool = ... + ) -> None: ... def get_file(self, key: str) -> IO[bytes]: ... def get_labels(self) -> List[str]: ... diff --git a/stdlib/netrc.pyi b/stdlib/netrc.pyi index 20a0513ea..b71c4b315 100644 --- a/stdlib/netrc.pyi +++ b/stdlib/netrc.pyi @@ -1,11 +1,11 @@ -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from typing import Dict, List, Optional, Tuple class NetrcParseError(Exception): filename: Optional[str] lineno: Optional[int] msg: str - def __init__(self, msg: str, filename: Optional[AnyPath] = ..., lineno: Optional[int] = ...) -> None: ... + def __init__(self, msg: str, filename: Optional[StrOrBytesPath] = ..., lineno: Optional[int] = ...) -> None: ... # (login, account, password) tuple _NetrcTuple = Tuple[str, Optional[str], Optional[str]] @@ -13,5 +13,5 @@ _NetrcTuple = Tuple[str, Optional[str], Optional[str]] class netrc: hosts: Dict[str, _NetrcTuple] macros: Dict[str, List[str]] - def __init__(self, file: Optional[AnyPath] = ...) -> None: ... + def __init__(self, file: Optional[StrOrBytesPath] = ...) -> None: ... def authenticators(self, host: str) -> Optional[_NetrcTuple]: ... diff --git a/stdlib/os/__init__.pyi b/stdlib/os/__init__.pyi index c79d478c6..5de46ca03 100644 --- a/stdlib/os/__init__.pyi +++ b/stdlib/os/__init__.pyi @@ -1,12 +1,12 @@ import sys from _typeshed import ( - AnyPath, FileDescriptorLike, OpenBinaryMode, OpenBinaryModeReading, OpenBinaryModeUpdating, OpenBinaryModeWriting, OpenTextMode, + StrOrBytesPath, StrPath, ) from builtins import OSError @@ -311,7 +311,7 @@ class stat_result: class PathLike(Protocol[_AnyStr_co]): def __fspath__(self) -> _AnyStr_co: ... -_FdOrAnyPath = Union[int, AnyPath] +_FdOrAnyPath = Union[int, StrOrBytesPath] class DirEntry(Generic[AnyStr]): # This is what the scandir interator yields @@ -368,8 +368,8 @@ if sys.platform != "win32": f_namemax: int # ----- os function stubs ----- -def fsencode(filename: AnyPath) -> bytes: ... -def fsdecode(filename: AnyPath) -> str: ... +def fsencode(filename: StrOrBytesPath) -> bytes: ... +def fsdecode(filename: StrOrBytesPath) -> str: ... @overload def fspath(path: str) -> str: ... @overload @@ -528,7 +528,7 @@ else: def fstat(fd: int) -> stat_result: ... def fsync(fd: FileDescriptorLike) -> None: ... def lseek(__fd: int, __position: int, __how: int) -> int: ... -def open(path: AnyPath, flags: int, mode: int = ..., *, dir_fd: Optional[int] = ...) -> int: ... +def open(path: StrOrBytesPath, flags: int, mode: int = ..., *, dir_fd: Optional[int] = ...) -> int: ... def pipe() -> Tuple[int, int]: ... def read(__fd: int, __length: int) -> bytes: ... @@ -595,43 +595,52 @@ def getcwdb() -> bytes: ... def chmod(path: _FdOrAnyPath, mode: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> None: ... if sys.platform != "win32": - def chflags(path: AnyPath, flags: int, follow_symlinks: bool = ...) -> None: ... # some flavors of Unix + def chflags(path: StrOrBytesPath, flags: int, follow_symlinks: bool = ...) -> None: ... # some flavors of Unix def chown( path: _FdOrAnyPath, uid: int, gid: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ... ) -> None: ... # Unix only if sys.platform != "win32": # Unix only - def chroot(path: AnyPath) -> None: ... - def lchflags(path: AnyPath, flags: int) -> None: ... - def lchmod(path: AnyPath, mode: int) -> None: ... - def lchown(path: AnyPath, uid: int, gid: int) -> None: ... + def chroot(path: StrOrBytesPath) -> None: ... + def lchflags(path: StrOrBytesPath, flags: int) -> None: ... + def lchmod(path: StrOrBytesPath, mode: int) -> None: ... + def lchown(path: StrOrBytesPath, uid: int, gid: int) -> None: ... def link( - src: AnyPath, dst: AnyPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ..., follow_symlinks: bool = ... + src: StrOrBytesPath, + dst: StrOrBytesPath, + *, + src_dir_fd: Optional[int] = ..., + dst_dir_fd: Optional[int] = ..., + follow_symlinks: bool = ..., ) -> None: ... -def lstat(path: AnyPath, *, dir_fd: Optional[int] = ...) -> stat_result: ... -def mkdir(path: AnyPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... +def lstat(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> stat_result: ... +def mkdir(path: StrOrBytesPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... if sys.platform != "win32": - def mkfifo(path: AnyPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... # Unix only + def mkfifo(path: StrOrBytesPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... # Unix only -def makedirs(name: AnyPath, mode: int = ..., exist_ok: bool = ...) -> None: ... +def makedirs(name: StrOrBytesPath, mode: int = ..., exist_ok: bool = ...) -> None: ... if sys.platform != "win32": - def mknod(path: AnyPath, mode: int = ..., device: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... + def mknod(path: StrOrBytesPath, mode: int = ..., device: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... def major(__device: int) -> int: ... def minor(__device: int) -> int: ... def makedev(__major: int, __minor: int) -> int: ... def pathconf(path: _FdOrAnyPath, name: Union[str, int]) -> int: ... # Unix only def readlink(path: Union[AnyStr, PathLike[AnyStr]], *, dir_fd: Optional[int] = ...) -> AnyStr: ... -def remove(path: AnyPath, *, dir_fd: Optional[int] = ...) -> None: ... -def removedirs(name: AnyPath) -> None: ... -def rename(src: AnyPath, dst: AnyPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...) -> None: ... -def renames(old: AnyPath, new: AnyPath) -> None: ... -def replace(src: AnyPath, dst: AnyPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...) -> None: ... -def rmdir(path: AnyPath, *, dir_fd: Optional[int] = ...) -> None: ... +def remove(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ... +def removedirs(name: StrOrBytesPath) -> None: ... +def rename( + src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ... +) -> None: ... +def renames(old: StrOrBytesPath, new: StrOrBytesPath) -> None: ... +def replace( + src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ... +) -> None: ... +def rmdir(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ... class _ScandirIterator(Iterator[DirEntry[AnyStr]], ContextManager[_ScandirIterator[AnyStr]]): def __next__(self) -> DirEntry[AnyStr]: ... @@ -662,13 +671,15 @@ if sys.version_info < (3, 7): if sys.platform != "win32": def statvfs(path: _FdOrAnyPath) -> statvfs_result: ... # Unix only -def symlink(src: AnyPath, dst: AnyPath, target_is_directory: bool = ..., *, dir_fd: Optional[int] = ...) -> None: ... +def symlink( + src: StrOrBytesPath, dst: StrOrBytesPath, target_is_directory: bool = ..., *, dir_fd: Optional[int] = ... +) -> None: ... if sys.platform != "win32": def sync() -> None: ... # Unix only def truncate(path: _FdOrAnyPath, length: int) -> None: ... # Unix only up to version 3.4 -def unlink(path: AnyPath, *, dir_fd: Optional[int] = ...) -> None: ... +def unlink(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ... def utime( path: _FdOrAnyPath, times: Optional[Union[Tuple[int, int], Tuple[float, float]]] = ..., @@ -714,22 +725,22 @@ if sys.platform != "win32": dir_fd: Optional[int] = ..., ) -> Iterator[Tuple[str, List[str], List[str], int]]: ... if sys.platform == "linux": - def getxattr(path: _FdOrAnyPath, attribute: AnyPath, *, follow_symlinks: bool = ...) -> bytes: ... + def getxattr(path: _FdOrAnyPath, attribute: StrOrBytesPath, *, follow_symlinks: bool = ...) -> bytes: ... def listxattr(path: Optional[_FdOrAnyPath] = ..., *, follow_symlinks: bool = ...) -> List[str]: ... - def removexattr(path: _FdOrAnyPath, attribute: AnyPath, *, follow_symlinks: bool = ...) -> None: ... + def removexattr(path: _FdOrAnyPath, attribute: StrOrBytesPath, *, follow_symlinks: bool = ...) -> None: ... def setxattr( - path: _FdOrAnyPath, attribute: AnyPath, value: bytes, flags: int = ..., *, follow_symlinks: bool = ... + path: _FdOrAnyPath, attribute: StrOrBytesPath, value: bytes, flags: int = ..., *, follow_symlinks: bool = ... ) -> None: ... def abort() -> NoReturn: ... # These are defined as execl(file, *args) but the first *arg is mandatory. -def execl(file: AnyPath, __arg0: AnyPath, *args: AnyPath) -> NoReturn: ... -def execlp(file: AnyPath, __arg0: AnyPath, *args: AnyPath) -> NoReturn: ... +def execl(file: StrOrBytesPath, __arg0: StrOrBytesPath, *args: StrOrBytesPath) -> NoReturn: ... +def execlp(file: StrOrBytesPath, __arg0: StrOrBytesPath, *args: StrOrBytesPath) -> NoReturn: ... # These are: execle(file, *args, env) but env is pulled from the last element of the args. -def execle(file: AnyPath, __arg0: AnyPath, *args: Any) -> NoReturn: ... -def execlpe(file: AnyPath, __arg0: AnyPath, *args: Any) -> NoReturn: ... +def execle(file: StrOrBytesPath, __arg0: StrOrBytesPath, *args: Any) -> NoReturn: ... +def execlpe(file: StrOrBytesPath, __arg0: StrOrBytesPath, *args: Any) -> NoReturn: ... # The docs say `args: tuple or list of strings` # The implementation enforces tuple or list so we can't use Sequence. @@ -737,7 +748,7 @@ def execlpe(file: AnyPath, __arg0: AnyPath, *args: Any) -> NoReturn: ... # in practice, and doing so would explode the number of combinations in this already long union. # All these combinations are necessary due to List being invariant. _ExecVArgs = Union[ - Tuple[AnyPath, ...], + Tuple[StrOrBytesPath, ...], List[bytes], List[str], List[PathLike[Any]], @@ -748,10 +759,10 @@ _ExecVArgs = Union[ ] _ExecEnv = Union[Mapping[bytes, Union[bytes, str]], Mapping[str, Union[bytes, str]]] -def execv(__path: AnyPath, __argv: _ExecVArgs) -> NoReturn: ... +def execv(__path: StrOrBytesPath, __argv: _ExecVArgs) -> NoReturn: ... def execve(path: _FdOrAnyPath, argv: _ExecVArgs, env: _ExecEnv) -> NoReturn: ... -def execvp(file: AnyPath, args: _ExecVArgs) -> NoReturn: ... -def execvpe(file: AnyPath, args: _ExecVArgs, env: _ExecEnv) -> NoReturn: ... +def execvp(file: StrOrBytesPath, args: _ExecVArgs) -> NoReturn: ... +def execvpe(file: StrOrBytesPath, args: _ExecVArgs, env: _ExecEnv) -> NoReturn: ... def _exit(status: int) -> NoReturn: ... def kill(__pid: int, __signal: int) -> None: ... @@ -769,30 +780,30 @@ class _wrap_close(_TextIOWrapper): def close(self) -> Optional[int]: ... # type: ignore def popen(cmd: str, mode: str = ..., buffering: int = ...) -> _wrap_close: ... -def spawnl(mode: int, file: AnyPath, arg0: AnyPath, *args: AnyPath) -> int: ... -def spawnle(mode: int, file: AnyPath, arg0: AnyPath, *args: Any) -> int: ... # Imprecise sig +def spawnl(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: StrOrBytesPath) -> int: ... +def spawnle(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: Any) -> int: ... # Imprecise sig if sys.platform != "win32": - def spawnv(mode: int, file: AnyPath, args: _ExecVArgs) -> int: ... - def spawnve(mode: int, file: AnyPath, args: _ExecVArgs, env: _ExecEnv) -> int: ... + def spawnv(mode: int, file: StrOrBytesPath, args: _ExecVArgs) -> int: ... + def spawnve(mode: int, file: StrOrBytesPath, args: _ExecVArgs, env: _ExecEnv) -> int: ... else: - def spawnv(__mode: int, __path: AnyPath, __argv: _ExecVArgs) -> int: ... - def spawnve(__mode: int, __path: AnyPath, __argv: _ExecVArgs, __env: _ExecEnv) -> int: ... + def spawnv(__mode: int, __path: StrOrBytesPath, __argv: _ExecVArgs) -> int: ... + def spawnve(__mode: int, __path: StrOrBytesPath, __argv: _ExecVArgs, __env: _ExecEnv) -> int: ... -def system(command: AnyPath) -> int: ... +def system(command: StrOrBytesPath) -> int: ... def times() -> times_result: ... def waitpid(__pid: int, __options: int) -> Tuple[int, int]: ... if sys.platform == "win32": - def startfile(path: AnyPath, operation: Optional[str] = ...) -> None: ... + def startfile(path: StrOrBytesPath, operation: Optional[str] = ...) -> None: ... else: # Unix only - def spawnlp(mode: int, file: AnyPath, arg0: AnyPath, *args: AnyPath) -> int: ... - def spawnlpe(mode: int, file: AnyPath, arg0: AnyPath, *args: Any) -> int: ... # Imprecise signature - def spawnvp(mode: int, file: AnyPath, args: _ExecVArgs) -> int: ... - def spawnvpe(mode: int, file: AnyPath, args: _ExecVArgs, env: _ExecEnv) -> int: ... + def spawnlp(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: StrOrBytesPath) -> int: ... + def spawnlpe(mode: int, file: StrOrBytesPath, arg0: StrOrBytesPath, *args: Any) -> int: ... # Imprecise signature + def spawnvp(mode: int, file: StrOrBytesPath, args: _ExecVArgs) -> int: ... + def spawnvpe(mode: int, file: StrOrBytesPath, args: _ExecVArgs, env: _ExecEnv) -> int: ... def wait() -> Tuple[int, int]: ... # Unix only if sys.platform != "darwin": from posix import waitid_result diff --git a/stdlib/parser.pyi b/stdlib/parser.pyi index 9fb26f9e3..1ad59da02 100644 --- a/stdlib/parser.pyi +++ b/stdlib/parser.pyi @@ -1,4 +1,4 @@ -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from types import CodeType from typing import Any, List, Sequence, Tuple @@ -8,14 +8,14 @@ def sequence2st(sequence: Sequence[Any]) -> STType: ... def tuple2st(sequence: Sequence[Any]) -> STType: ... def st2list(st: STType, line_info: bool = ..., col_info: bool = ...) -> List[Any]: ... def st2tuple(st: STType, line_info: bool = ..., col_info: bool = ...) -> Tuple[Any]: ... -def compilest(st: STType, filename: AnyPath = ...) -> CodeType: ... +def compilest(st: STType, filename: StrOrBytesPath = ...) -> CodeType: ... def isexpr(st: STType) -> bool: ... def issuite(st: STType) -> bool: ... class ParserError(Exception): ... class STType: - def compile(self, filename: AnyPath = ...) -> CodeType: ... + def compile(self, filename: StrOrBytesPath = ...) -> CodeType: ... def isexpr(self) -> bool: ... def issuite(self) -> bool: ... def tolist(self, line_info: bool = ..., col_info: bool = ...) -> List[Any]: ... diff --git a/stdlib/posixpath.pyi b/stdlib/posixpath.pyi index 98176eaa0..4f0fcb7ed 100644 --- a/stdlib/posixpath.pyi +++ b/stdlib/posixpath.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import AnyPath, BytesPath, StrPath +from _typeshed import BytesPath, StrOrBytesPath, StrPath from genericpath import ( commonprefix as commonprefix, exists as exists, @@ -93,7 +93,7 @@ def splitdrive(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... def splitext(p: PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ... @overload def splitext(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... -def isabs(s: AnyPath) -> bool: ... -def islink(path: AnyPath) -> bool: ... -def ismount(path: AnyPath) -> bool: ... -def lexists(path: AnyPath) -> bool: ... +def isabs(s: StrOrBytesPath) -> bool: ... +def islink(path: StrOrBytesPath) -> bool: ... +def ismount(path: StrOrBytesPath) -> bool: ... +def lexists(path: StrOrBytesPath) -> bool: ... diff --git a/stdlib/profile.pyi b/stdlib/profile.pyi index cc769b604..8052ede76 100644 --- a/stdlib/profile.pyi +++ b/stdlib/profile.pyi @@ -1,4 +1,4 @@ -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from typing import Any, Callable, Dict, Optional, Tuple, TypeVar, Union def run(statement: str, filename: Optional[str] = ..., sort: Union[str, int] = ...) -> None: ... @@ -18,7 +18,7 @@ class Profile: def simulate_call(self, name: str) -> None: ... def simulate_cmd_complete(self) -> None: ... def print_stats(self, sort: Union[str, int] = ...) -> None: ... - def dump_stats(self, file: AnyPath) -> None: ... + def dump_stats(self, file: StrOrBytesPath) -> None: ... def create_stats(self) -> None: ... def snapshot_stats(self) -> None: ... def run(self: _SelfT, cmd: str) -> _SelfT: ... diff --git a/stdlib/pstats.pyi b/stdlib/pstats.pyi index b8d581960..80ce44ddd 100644 --- a/stdlib/pstats.pyi +++ b/stdlib/pstats.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from cProfile import Profile as _cProfile from profile import Profile from typing import IO, Any, Dict, Iterable, List, Optional, Tuple, TypeVar, Union, overload @@ -32,7 +32,7 @@ class Stats: def load_stats(self, arg: Union[None, str, Profile, _cProfile]) -> None: ... def get_top_level_stats(self) -> None: ... def add(self: _T, *arg_list: Union[None, str, Profile, _cProfile, _T]) -> _T: ... - def dump_stats(self, filename: AnyPath) -> None: ... + def dump_stats(self, filename: StrOrBytesPath) -> None: ... def get_sort_arg_defs(self) -> Dict[str, Tuple[Tuple[Tuple[int, int], ...], str]]: ... @overload def sort_stats(self: _T, field: int) -> _T: ... diff --git a/stdlib/readline.pyi b/stdlib/readline.pyi index 6a3a45806..39f0001d0 100644 --- a/stdlib/readline.pyi +++ b/stdlib/readline.pyi @@ -1,17 +1,17 @@ -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from typing import Callable, Optional, Sequence _CompleterT = Optional[Callable[[str, int], Optional[str]]] _CompDispT = Optional[Callable[[str, Sequence[str], int], None]] def parse_and_bind(__string: str) -> None: ... -def read_init_file(__filename: Optional[AnyPath] = ...) -> None: ... +def read_init_file(__filename: Optional[StrOrBytesPath] = ...) -> None: ... def get_line_buffer() -> str: ... def insert_text(__string: str) -> None: ... def redisplay() -> None: ... -def read_history_file(__filename: Optional[AnyPath] = ...) -> None: ... -def write_history_file(__filename: Optional[AnyPath] = ...) -> None: ... -def append_history_file(__nelements: int, __filename: Optional[AnyPath] = ...) -> None: ... +def read_history_file(__filename: Optional[StrOrBytesPath] = ...) -> None: ... +def write_history_file(__filename: Optional[StrOrBytesPath] = ...) -> None: ... +def append_history_file(__nelements: int, __filename: Optional[StrOrBytesPath] = ...) -> None: ... def get_history_length() -> int: ... def set_history_length(__length: int) -> None: ... def clear_history() -> None: ... diff --git a/stdlib/sndhdr.pyi b/stdlib/sndhdr.pyi index b86b3b16e..4f8ab2652 100644 --- a/stdlib/sndhdr.pyi +++ b/stdlib/sndhdr.pyi @@ -1,4 +1,4 @@ -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from typing import NamedTuple, Optional, Union class SndHeaders(NamedTuple): @@ -8,5 +8,5 @@ class SndHeaders(NamedTuple): nframes: int sampwidth: Union[int, str] -def what(filename: AnyPath) -> Optional[SndHeaders]: ... -def whathdr(filename: AnyPath) -> Optional[SndHeaders]: ... +def what(filename: StrOrBytesPath) -> Optional[SndHeaders]: ... +def whathdr(filename: StrOrBytesPath) -> Optional[SndHeaders]: ... diff --git a/stdlib/sqlite3/dbapi2.pyi b/stdlib/sqlite3/dbapi2.pyi index 159e55fc9..c53141856 100644 --- a/stdlib/sqlite3/dbapi2.pyi +++ b/stdlib/sqlite3/dbapi2.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from datetime import date, datetime, time from typing import Any, Callable, Generator, Iterable, Iterator, List, Optional, Protocol, Tuple, Type, TypeVar, Union @@ -66,7 +66,7 @@ def complete_statement(sql: str) -> bool: ... if sys.version_info >= (3, 7): def connect( - database: AnyPath, + database: StrOrBytesPath, timeout: float = ..., detect_types: int = ..., isolation_level: Optional[str] = ..., diff --git a/stdlib/subprocess.pyi b/stdlib/subprocess.pyi index 3a0361ca0..9a431f082 100644 --- a/stdlib/subprocess.pyi +++ b/stdlib/subprocess.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from types import TracebackType from typing import IO, Any, AnyStr, Callable, Generic, Mapping, Optional, Sequence, Tuple, Type, TypeVar, Union, overload from typing_extensions import Literal @@ -24,15 +24,15 @@ if sys.version_info >= (3, 9): _FILE = Union[None, int, IO[Any]] _TXT = Union[bytes, str] if sys.version_info >= (3, 8): - _CMD = Union[AnyPath, Sequence[AnyPath]] + _CMD = Union[StrOrBytesPath, Sequence[StrOrBytesPath]] else: # Python 3.6 doesn't support _CMD being a single PathLike. # See: https://bugs.python.org/issue31961 - _CMD = Union[_TXT, Sequence[AnyPath]] + _CMD = Union[_TXT, Sequence[StrOrBytesPath]] if sys.platform == "win32": _ENV = Mapping[str, str] else: - _ENV = Union[Mapping[bytes, AnyPath], Mapping[str, AnyPath]] + _ENV = Union[Mapping[bytes, StrOrBytesPath], Mapping[str, StrOrBytesPath]] _S = TypeVar("_S") _T = TypeVar("_T") @@ -56,14 +56,14 @@ if sys.version_info >= (3, 7): def run( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., @@ -84,14 +84,14 @@ if sys.version_info >= (3, 7): def run( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., @@ -112,14 +112,14 @@ if sys.version_info >= (3, 7): def run( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., @@ -140,14 +140,14 @@ if sys.version_info >= (3, 7): def run( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., *, universal_newlines: Literal[True], @@ -169,14 +169,14 @@ if sys.version_info >= (3, 7): def run( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: Literal[False] = ..., startupinfo: Any = ..., @@ -197,14 +197,14 @@ if sys.version_info >= (3, 7): def run( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., @@ -228,14 +228,14 @@ else: def run( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., @@ -254,14 +254,14 @@ else: def run( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., @@ -280,14 +280,14 @@ else: def run( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., *, universal_newlines: Literal[True], @@ -307,14 +307,14 @@ else: def run( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: Literal[False] = ..., startupinfo: Any = ..., @@ -333,14 +333,14 @@ else: def run( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., @@ -360,14 +360,14 @@ else: def call( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., @@ -383,14 +383,14 @@ def call( def check_call( args: _CMD, bufsize: int = ..., - executable: AnyPath = ..., + executable: StrOrBytesPath = ..., stdin: _FILE = ..., stdout: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., @@ -407,13 +407,13 @@ if sys.version_info >= (3, 7): def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., @@ -432,13 +432,13 @@ if sys.version_info >= (3, 7): def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., @@ -457,13 +457,13 @@ if sys.version_info >= (3, 7): def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., @@ -482,13 +482,13 @@ if sys.version_info >= (3, 7): def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., *, universal_newlines: Literal[True], @@ -508,13 +508,13 @@ if sys.version_info >= (3, 7): def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: Literal[False] = ..., startupinfo: Any = ..., @@ -533,13 +533,13 @@ if sys.version_info >= (3, 7): def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., @@ -560,13 +560,13 @@ else: def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., @@ -584,13 +584,13 @@ else: def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., @@ -608,13 +608,13 @@ else: def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., startupinfo: Any = ..., creationflags: int = ..., @@ -632,13 +632,13 @@ else: def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: Literal[False] = ..., startupinfo: Any = ..., @@ -656,13 +656,13 @@ else: def check_output( args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: _FILE = ..., stderr: _FILE = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Any = ..., @@ -724,14 +724,14 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: Optional[_FILE] = ..., stdout: Optional[_FILE] = ..., stderr: Optional[_FILE] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Optional[Any] = ..., @@ -749,14 +749,14 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: Optional[_FILE] = ..., stdout: Optional[_FILE] = ..., stderr: Optional[_FILE] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Optional[Any] = ..., @@ -774,14 +774,14 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: Optional[_FILE] = ..., stdout: Optional[_FILE] = ..., stderr: Optional[_FILE] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., *, universal_newlines: Literal[True], @@ -800,14 +800,14 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: Optional[_FILE] = ..., stdout: Optional[_FILE] = ..., stderr: Optional[_FILE] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Optional[Any] = ..., @@ -825,14 +825,14 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: Optional[_FILE] = ..., stdout: Optional[_FILE] = ..., stderr: Optional[_FILE] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: Literal[False] = ..., startupinfo: Optional[Any] = ..., @@ -850,14 +850,14 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: Optional[_FILE] = ..., stdout: Optional[_FILE] = ..., stderr: Optional[_FILE] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Optional[Any] = ..., @@ -876,14 +876,14 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: Optional[_FILE] = ..., stdout: Optional[_FILE] = ..., stderr: Optional[_FILE] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Optional[Any] = ..., @@ -900,14 +900,14 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: Optional[_FILE] = ..., stdout: Optional[_FILE] = ..., stderr: Optional[_FILE] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Optional[Any] = ..., @@ -924,14 +924,14 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: Optional[_FILE] = ..., stdout: Optional[_FILE] = ..., stderr: Optional[_FILE] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., *, universal_newlines: Literal[True], @@ -949,14 +949,14 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: Optional[_FILE] = ..., stdout: Optional[_FILE] = ..., stderr: Optional[_FILE] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: Literal[False] = ..., startupinfo: Optional[Any] = ..., @@ -973,14 +973,14 @@ class Popen(Generic[AnyStr]): cls, args: _CMD, bufsize: int = ..., - executable: Optional[AnyPath] = ..., + executable: Optional[StrOrBytesPath] = ..., stdin: Optional[_FILE] = ..., stdout: Optional[_FILE] = ..., stderr: Optional[_FILE] = ..., preexec_fn: Optional[Callable[[], Any]] = ..., close_fds: bool = ..., shell: bool = ..., - cwd: Optional[AnyPath] = ..., + cwd: Optional[StrOrBytesPath] = ..., env: Optional[_ENV] = ..., universal_newlines: bool = ..., startupinfo: Optional[Any] = ..., diff --git a/stdlib/tabnanny.pyi b/stdlib/tabnanny.pyi index 7784c9fc8..584c6d4e2 100644 --- a/stdlib/tabnanny.pyi +++ b/stdlib/tabnanny.pyi @@ -1,4 +1,4 @@ -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from typing import Iterable, Tuple verbose: int @@ -10,5 +10,5 @@ class NannyNag(Exception): def get_msg(self) -> str: ... def get_line(self) -> str: ... -def check(file: AnyPath) -> None: ... +def check(file: StrOrBytesPath) -> None: ... def process_tokens(tokens: Iterable[Tuple[int, str, Tuple[int, int], Tuple[int, int], str]]) -> None: ... diff --git a/stdlib/tarfile.pyi b/stdlib/tarfile.pyi index 8dda5b803..74ebd714c 100644 --- a/stdlib/tarfile.pyi +++ b/stdlib/tarfile.pyi @@ -1,6 +1,6 @@ import io import sys -from _typeshed import AnyPath, StrPath +from _typeshed import StrOrBytesPath, StrPath from types import TracebackType from typing import IO, Callable, Dict, Iterable, Iterator, List, Mapping, Optional, Set, Tuple, Type, Union @@ -50,7 +50,7 @@ PAX_NAME_FIELDS: Set[str] ENCODING: str def open( - name: Optional[AnyPath] = ..., + name: Optional[StrOrBytesPath] = ..., mode: str = ..., fileobj: Optional[IO[bytes]] = ..., bufsize: int = ..., @@ -72,7 +72,7 @@ class ExFileObject(io.BufferedReader): class TarFile(Iterable[TarInfo]): OPEN_METH: Mapping[str, str] - name: Optional[AnyPath] + name: Optional[StrOrBytesPath] mode: str fileobj: Optional[IO[bytes]] format: Optional[int] @@ -88,7 +88,7 @@ class TarFile(Iterable[TarInfo]): offset: int # undocumented def __init__( self, - name: Optional[AnyPath] = ..., + name: Optional[StrOrBytesPath] = ..., mode: str = ..., fileobj: Optional[IO[bytes]] = ..., format: Optional[int] = ..., @@ -110,7 +110,7 @@ class TarFile(Iterable[TarInfo]): @classmethod def open( cls, - name: Optional[AnyPath] = ..., + name: Optional[StrOrBytesPath] = ..., mode: str = ..., fileobj: Optional[IO[bytes]] = ..., bufsize: int = ..., @@ -128,7 +128,7 @@ class TarFile(Iterable[TarInfo]): @classmethod def taropen( cls, - name: Optional[AnyPath], + name: Optional[StrOrBytesPath], mode: str = ..., fileobj: Optional[IO[bytes]] = ..., *, @@ -145,7 +145,7 @@ class TarFile(Iterable[TarInfo]): @classmethod def gzopen( cls, - name: Optional[AnyPath], + name: Optional[StrOrBytesPath], mode: str = ..., fileobj: Optional[IO[bytes]] = ..., compresslevel: int = ..., @@ -162,7 +162,7 @@ class TarFile(Iterable[TarInfo]): @classmethod def bz2open( cls, - name: Optional[AnyPath], + name: Optional[StrOrBytesPath], mode: str = ..., fileobj: Optional[IO[bytes]] = ..., compresslevel: int = ..., @@ -179,7 +179,7 @@ class TarFile(Iterable[TarInfo]): @classmethod def xzopen( cls, - name: Optional[AnyPath], + name: Optional[StrOrBytesPath], mode: str = ..., fileobj: Optional[IO[bytes]] = ..., preset: Optional[int] = ..., @@ -199,21 +199,21 @@ class TarFile(Iterable[TarInfo]): def list(self, verbose: bool = ..., *, members: Optional[List[TarInfo]] = ...) -> None: ... def next(self) -> Optional[TarInfo]: ... def extractall( - self, path: AnyPath = ..., members: Optional[Iterable[TarInfo]] = ..., *, numeric_owner: bool = ... + self, path: StrOrBytesPath = ..., members: Optional[Iterable[TarInfo]] = ..., *, numeric_owner: bool = ... ) -> None: ... def extract( - self, member: Union[str, TarInfo], path: AnyPath = ..., set_attrs: bool = ..., *, numeric_owner: bool = ... + self, member: Union[str, TarInfo], path: StrOrBytesPath = ..., set_attrs: bool = ..., *, numeric_owner: bool = ... ) -> None: ... def extractfile(self, member: Union[str, TarInfo]) -> Optional[IO[bytes]]: ... - def makedir(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - def makefile(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - def makeunknown(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - def makefifo(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - def makedev(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - def makelink(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - def chown(self, tarinfo: TarInfo, targetpath: AnyPath, numeric_owner: bool) -> None: ... # undocumented - def chmod(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented - def utime(self, tarinfo: TarInfo, targetpath: AnyPath) -> None: ... # undocumented + def makedir(self, tarinfo: TarInfo, targetpath: StrOrBytesPath) -> None: ... # undocumented + def makefile(self, tarinfo: TarInfo, targetpath: StrOrBytesPath) -> None: ... # undocumented + def makeunknown(self, tarinfo: TarInfo, targetpath: StrOrBytesPath) -> None: ... # undocumented + def makefifo(self, tarinfo: TarInfo, targetpath: StrOrBytesPath) -> None: ... # undocumented + def makedev(self, tarinfo: TarInfo, targetpath: StrOrBytesPath) -> None: ... # undocumented + def makelink(self, tarinfo: TarInfo, targetpath: StrOrBytesPath) -> None: ... # undocumented + def chown(self, tarinfo: TarInfo, targetpath: StrOrBytesPath, numeric_owner: bool) -> None: ... # undocumented + def chmod(self, tarinfo: TarInfo, targetpath: StrOrBytesPath) -> None: ... # undocumented + def utime(self, tarinfo: TarInfo, targetpath: StrOrBytesPath) -> None: ... # undocumented if sys.version_info >= (3, 7): def add( self, @@ -240,10 +240,10 @@ class TarFile(Iterable[TarInfo]): def close(self) -> None: ... if sys.version_info >= (3, 9): - def is_tarfile(name: Union[AnyPath, IO[bytes]]) -> bool: ... + def is_tarfile(name: Union[StrOrBytesPath, IO[bytes]]) -> bool: ... else: - def is_tarfile(name: AnyPath) -> bool: ... + def is_tarfile(name: StrOrBytesPath) -> bool: ... if sys.version_info < (3, 8): def filemode(mode: int) -> str: ... # undocumented diff --git a/stdlib/tkinter/__init__.pyi b/stdlib/tkinter/__init__.pyi index db1dd1584..8d328abae 100644 --- a/stdlib/tkinter/__init__.pyi +++ b/stdlib/tkinter/__init__.pyi @@ -1,6 +1,6 @@ import _tkinter import sys -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from enum import Enum from tkinter.constants import * # comment this out to find undefined identifier names with flake8 from tkinter.font import _FontDescription @@ -2791,7 +2791,7 @@ class PhotoImage(Image): *, data: Union[str, bytes] = ..., # not same as data argument of put() format: str = ..., - file: AnyPath = ..., + file: StrOrBytesPath = ..., gamma: float = ..., height: int = ..., palette: Union[int, str] = ..., @@ -2802,7 +2802,7 @@ class PhotoImage(Image): *, data: Union[str, bytes] = ..., format: str = ..., - file: AnyPath = ..., + file: StrOrBytesPath = ..., gamma: float = ..., height: int = ..., palette: Union[int, str] = ..., @@ -2819,7 +2819,9 @@ class PhotoImage(Image): def put( self, data: Union[str, _TkinterSequence[str], _TkinterSequence2D[_Color]], to: Optional[Tuple[int, int]] = ... ) -> None: ... - def write(self, filename: AnyPath, format: Optional[str] = ..., from_coords: Optional[Tuple[int, int]] = ...) -> None: ... + def write( + self, filename: StrOrBytesPath, format: Optional[str] = ..., from_coords: Optional[Tuple[int, int]] = ... + ) -> None: ... if sys.version_info >= (3, 8): def transparency_get(self, x: int, y: int) -> bool: ... def transparency_set(self, x: int, y: int, boolean: bool) -> None: ... @@ -2833,10 +2835,10 @@ class BitmapImage(Image): *, background: _Color = ..., data: Union[str, bytes] = ..., - file: AnyPath = ..., + file: StrOrBytesPath = ..., foreground: _Color = ..., maskdata: str = ..., - maskfile: AnyPath = ..., + maskfile: StrOrBytesPath = ..., ) -> None: ... def image_names() -> Tuple[str, ...]: ... diff --git a/stdlib/tokenize.pyi b/stdlib/tokenize.pyi index 1df951bc5..a6e6abae5 100644 --- a/stdlib/tokenize.pyi +++ b/stdlib/tokenize.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from builtins import open as _builtin_open from token import * # noqa: F403 from typing import ( @@ -62,7 +62,7 @@ def untokenize(iterable: Iterable[_Token]) -> Any: ... def detect_encoding(readline: Callable[[], bytes]) -> Tuple[str, Sequence[bytes]]: ... def tokenize(readline: Callable[[], bytes]) -> Generator[TokenInfo, None, None]: ... def generate_tokens(readline: Callable[[], str]) -> Generator[TokenInfo, None, None]: ... # undocumented -def open(filename: Union[AnyPath, int]) -> TextIO: ... +def open(filename: Union[StrOrBytesPath, int]) -> TextIO: ... def group(*choices: str) -> str: ... # undocumented def any(*choices: str) -> str: ... # undocumented def maybe(*choices: str) -> str: ... # undocumented diff --git a/stdlib/urllib/request.pyi b/stdlib/urllib/request.pyi index 96fd3c1dd..60ccdf2dd 100644 --- a/stdlib/urllib/request.pyi +++ b/stdlib/urllib/request.pyi @@ -1,6 +1,6 @@ import ssl import sys -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from email.message import Message from http.client import HTTPMessage, HTTPResponse, _HTTPConnectionProtocol from http.cookiejar import CookieJar @@ -271,7 +271,7 @@ class HTTPErrorProcessor(BaseHandler): def urlretrieve( url: str, - filename: Optional[AnyPath] = ..., + filename: Optional[StrOrBytesPath] = ..., reporthook: Optional[Callable[[int, int, int], None]] = ..., data: Optional[bytes] = ..., ) -> Tuple[str, HTTPMessage]: ... diff --git a/stdlib/venv/__init__.pyi b/stdlib/venv/__init__.pyi index d44d17ea9..fe49ea656 100644 --- a/stdlib/venv/__init__.pyi +++ b/stdlib/venv/__init__.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from types import SimpleNamespace from typing import Optional, Sequence @@ -32,11 +32,13 @@ class EnvBuilder: with_pip: bool = ..., prompt: Optional[str] = ..., ) -> None: ... - def create(self, env_dir: AnyPath) -> None: ... - def clear_directory(self, path: AnyPath) -> None: ... # undocumented - def ensure_directories(self, env_dir: AnyPath) -> SimpleNamespace: ... + def create(self, env_dir: StrOrBytesPath) -> None: ... + def clear_directory(self, path: StrOrBytesPath) -> None: ... # undocumented + def ensure_directories(self, env_dir: StrOrBytesPath) -> SimpleNamespace: ... def create_configuration(self, context: SimpleNamespace) -> None: ... - def symlink_or_copy(self, src: AnyPath, dst: AnyPath, relative_symlinks_ok: bool = ...) -> None: ... # undocumented + def symlink_or_copy( + self, src: StrOrBytesPath, dst: StrOrBytesPath, relative_symlinks_ok: bool = ... + ) -> None: ... # undocumented def setup_python(self, context: SimpleNamespace) -> None: ... def _setup_pip(self, context: SimpleNamespace) -> None: ... # undocumented def setup_scripts(self, context: SimpleNamespace) -> None: ... @@ -48,7 +50,7 @@ class EnvBuilder: if sys.version_info >= (3, 9): def create( - env_dir: AnyPath, + env_dir: StrOrBytesPath, system_site_packages: bool = ..., clear: bool = ..., symlinks: bool = ..., @@ -59,7 +61,7 @@ if sys.version_info >= (3, 9): else: def create( - env_dir: AnyPath, + env_dir: StrOrBytesPath, system_site_packages: bool = ..., clear: bool = ..., symlinks: bool = ..., diff --git a/stdlib/xml/etree/ElementTree.pyi b/stdlib/xml/etree/ElementTree.pyi index 09bd32f01..8251071e8 100644 --- a/stdlib/xml/etree/ElementTree.pyi +++ b/stdlib/xml/etree/ElementTree.pyi @@ -1,5 +1,5 @@ import sys -from _typeshed import AnyPath, FileDescriptor, SupportsWrite +from _typeshed import FileDescriptor, StrOrBytesPath, SupportsWrite from typing import ( IO, Any, @@ -22,7 +22,7 @@ from typing import ( from typing_extensions import Literal _T = TypeVar("_T") -_File = Union[AnyPath, FileDescriptor, IO[Any]] +_File = Union[StrOrBytesPath, FileDescriptor, IO[Any]] VERSION: str diff --git a/stubs/Jinja2/jinja2/utils.pyi b/stubs/Jinja2/jinja2/utils.pyi index 3d1b1cccf..5345afc93 100644 --- a/stubs/Jinja2/jinja2/utils.pyi +++ b/stubs/Jinja2/jinja2/utils.pyi @@ -1,4 +1,4 @@ -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from typing import IO, Any, Callable, Iterable, Optional, Protocol, Text, TypeVar, Union from typing_extensions import Literal @@ -36,7 +36,7 @@ def select_autoescape( def consume(iterable: Iterable[object]) -> None: ... def clear_caches() -> None: ... def import_string(import_name: str, silent: bool = ...) -> Any: ... -def open_if_exists(filename: AnyPath, mode: str = ...) -> Optional[IO[Any]]: ... +def open_if_exists(filename: StrOrBytesPath, mode: str = ...) -> Optional[IO[Any]]: ... def object_type_repr(obj: object) -> str: ... def pformat(obj: object, verbose: bool = ...) -> str: ... def urlize( diff --git a/stubs/aiofiles/aiofiles/os.pyi b/stubs/aiofiles/aiofiles/os.pyi index 5144abe98..9b6a62dca 100644 --- a/stubs/aiofiles/aiofiles/os.pyi +++ b/stubs/aiofiles/aiofiles/os.pyi @@ -1,15 +1,17 @@ import sys -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from os import stat_result from typing import Optional, Sequence, Union, overload -_FdOrAnyPath = Union[int, AnyPath] +_FdOrAnyPath = Union[int, StrOrBytesPath] async def stat(path: _FdOrAnyPath, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> stat_result: ... -async def rename(src: AnyPath, dst: AnyPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...) -> None: ... -async def remove(path: AnyPath, *, dir_fd: Optional[int] = ...) -> None: ... -async def mkdir(path: AnyPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... -async def rmdir(path: AnyPath, *, dir_fd: Optional[int] = ...) -> None: ... +async def rename( + src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ... +) -> None: ... +async def remove(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ... +async def mkdir(path: StrOrBytesPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... +async def rmdir(path: StrOrBytesPath, *, dir_fd: Optional[int] = ...) -> None: ... if sys.platform != "win32": @overload diff --git a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi index dd6480404..ce0a52824 100644 --- a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi @@ -1,4 +1,11 @@ -from _typeshed import AnyPath, OpenBinaryMode, OpenBinaryModeReading, OpenBinaryModeUpdating, OpenBinaryModeWriting, OpenTextMode +from _typeshed import ( + OpenBinaryMode, + OpenBinaryModeReading, + OpenBinaryModeUpdating, + OpenBinaryModeWriting, + OpenTextMode, + StrOrBytesPath, +) from asyncio import AbstractEventLoop from typing import Any, Callable, Optional, Union, overload from typing_extensions import Literal @@ -7,7 +14,7 @@ from ..base import AiofilesContextManager from .binary import AsyncBufferedIOBase, AsyncBufferedReader, AsyncFileIO, _UnknownAsyncBinaryIO from .text import AsyncTextIOWrapper -_OpenFile = Union[AnyPath, int] +_OpenFile = Union[StrOrBytesPath, int] _Opener = Callable[[str, int], int] # Text mode: always returns AsyncTextIOWrapper diff --git a/stubs/aiofiles/aiofiles/threadpool/binary.pyi b/stubs/aiofiles/aiofiles/threadpool/binary.pyi index ecfd4ed12..1da36f688 100644 --- a/stubs/aiofiles/aiofiles/threadpool/binary.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/binary.pyi @@ -1,4 +1,4 @@ -from _typeshed import AnyPath, ReadableBuffer, WriteableBuffer +from _typeshed import ReadableBuffer, StrOrBytesPath, WriteableBuffer from io import FileIO from typing import Iterable, List, Optional, Union @@ -26,7 +26,7 @@ class _UnknownAsyncBinaryIO(AsyncBase[bytes]): @property def mode(self) -> str: ... @property - def name(self) -> Union[AnyPath, int]: ... + def name(self) -> Union[StrOrBytesPath, int]: ... class AsyncBufferedIOBase(_UnknownAsyncBinaryIO): async def read1(self, __size: int = ...) -> bytes: ... diff --git a/stubs/aiofiles/aiofiles/threadpool/text.pyi b/stubs/aiofiles/aiofiles/threadpool/text.pyi index 39588f8a3..3c087464e 100644 --- a/stubs/aiofiles/aiofiles/threadpool/text.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/text.pyi @@ -1,4 +1,4 @@ -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from typing import BinaryIO, Iterable, List, Optional, Tuple, Union from ..base import AsyncBase @@ -33,6 +33,6 @@ class AsyncTextIOWrapper(AsyncBase[str]): @property def newlines(self) -> Union[str, Tuple[str, ...], None]: ... @property - def name(self) -> Union[AnyPath, int]: ... + def name(self) -> Union[StrOrBytesPath, int]: ... @property def mode(self) -> str: ... diff --git a/stubs/atomicwrites/atomicwrites/__init__.pyi b/stubs/atomicwrites/atomicwrites/__init__.pyi index adf6803d6..d479ea430 100644 --- a/stubs/atomicwrites/atomicwrites/__init__.pyi +++ b/stubs/atomicwrites/atomicwrites/__init__.pyi @@ -1,16 +1,16 @@ -from _typeshed import AnyPath +from _typeshed import StrOrBytesPath from typing import IO, Any, AnyStr, Callable, ContextManager, Optional, Text, Type def replace_atomic(src: AnyStr, dst: AnyStr) -> None: ... def move_atomic(src: AnyStr, dst: AnyStr) -> None: ... class AtomicWriter(object): - def __init__(self, path: AnyPath, mode: Text = ..., overwrite: bool = ...) -> None: ... + def __init__(self, path: StrOrBytesPath, mode: Text = ..., overwrite: bool = ...) -> None: ... def open(self) -> ContextManager[IO[Any]]: ... def _open(self, get_fileobject: Callable[..., IO[AnyStr]]) -> ContextManager[IO[AnyStr]]: ... - def get_fileobject(self, dir: Optional[AnyPath] = ..., **kwargs: Any) -> IO[Any]: ... + def get_fileobject(self, dir: Optional[StrOrBytesPath] = ..., **kwargs: Any) -> IO[Any]: ... def sync(self, f: IO[Any]) -> None: ... def commit(self, f: IO[Any]) -> None: ... def rollback(self, f: IO[Any]) -> None: ... -def atomic_write(path: AnyPath, writer_cls: Type[AtomicWriter] = ..., **cls_kwargs: object) -> ContextManager[IO[Any]]: ... +def atomic_write(path: StrOrBytesPath, writer_cls: Type[AtomicWriter] = ..., **cls_kwargs: object) -> ContextManager[IO[Any]]: ...