mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-05 09:27:38 +08:00
apply black and isort (#4287)
* apply black and isort * move some type ignores
This commit is contained in:
@@ -1,13 +1,32 @@
|
||||
import sys
|
||||
from builtins import OSError as error
|
||||
from io import TextIOWrapper as _TextIOWrapper
|
||||
from posix import listdir as listdir, times_result
|
||||
import sys
|
||||
from typing import (
|
||||
Mapping, MutableMapping, Dict, List, Any, Tuple, Iterable, Iterator, NoReturn, overload, Union, AnyStr,
|
||||
Optional, Generic, Set, Callable, Sequence, NamedTuple, ContextManager, TypeVar
|
||||
Any,
|
||||
AnyStr,
|
||||
Callable,
|
||||
ContextManager,
|
||||
Dict,
|
||||
Generic,
|
||||
Iterable,
|
||||
Iterator,
|
||||
List,
|
||||
Mapping,
|
||||
MutableMapping,
|
||||
NamedTuple,
|
||||
NoReturn,
|
||||
Optional,
|
||||
Sequence,
|
||||
Set,
|
||||
Tuple,
|
||||
TypeVar,
|
||||
Union,
|
||||
overload,
|
||||
)
|
||||
|
||||
from _typeshed import AnyPath
|
||||
|
||||
from builtins import OSError as error
|
||||
from . import path as path
|
||||
|
||||
# We need to use something from path, or flake8 and pytype get unhappy
|
||||
@@ -24,7 +43,7 @@ supports_fd: Set[Callable[..., Any]]
|
||||
supports_effective_ids: Set[Callable[..., Any]]
|
||||
supports_follow_symlinks: Set[Callable[..., Any]]
|
||||
|
||||
if sys.platform != 'win32':
|
||||
if sys.platform != "win32":
|
||||
# Unix only
|
||||
PRIO_PROCESS: int
|
||||
PRIO_PGRP: int
|
||||
@@ -85,7 +104,7 @@ if sys.platform != "win32":
|
||||
SEEK_SET: int
|
||||
SEEK_CUR: int
|
||||
SEEK_END: int
|
||||
if sys.platform != 'win32':
|
||||
if sys.platform != "win32":
|
||||
SEEK_DATA: int # some flavors of Unix
|
||||
SEEK_HOLE: int # some flavors of Unix
|
||||
|
||||
@@ -99,27 +118,27 @@ O_TRUNC: int
|
||||
# We don't use sys.platform for O_* flags to denote platform-dependent APIs because some codes,
|
||||
# including tests for mypy, use a more finer way than sys.platform before using these APIs
|
||||
# See https://github.com/python/typeshed/pull/2286 for discussions
|
||||
O_DSYNC: int # Unix only
|
||||
O_RSYNC: int # Unix only
|
||||
O_SYNC: int # Unix only
|
||||
O_NDELAY: int # Unix only
|
||||
O_DSYNC: int # Unix only
|
||||
O_RSYNC: int # Unix only
|
||||
O_SYNC: int # Unix only
|
||||
O_NDELAY: int # Unix only
|
||||
O_NONBLOCK: int # Unix only
|
||||
O_NOCTTY: int # Unix only
|
||||
O_NOCTTY: int # Unix only
|
||||
O_CLOEXEC: int # Unix only
|
||||
O_SHLOCK: int # Unix only
|
||||
O_EXLOCK: int # Unix only
|
||||
O_BINARY: int # Windows only
|
||||
O_SHLOCK: int # Unix only
|
||||
O_EXLOCK: int # Unix only
|
||||
O_BINARY: int # Windows only
|
||||
O_NOINHERIT: int # Windows only
|
||||
O_SHORT_LIVED: int # Windows only
|
||||
O_TEMPORARY: int # Windows only
|
||||
O_RANDOM: int # Windows only
|
||||
O_RANDOM: int # Windows only
|
||||
O_SEQUENTIAL: int # Windows only
|
||||
O_TEXT: int # Windows only
|
||||
O_ASYNC: int # Gnu extension if in C library
|
||||
O_DIRECT: int # Gnu extension if in C library
|
||||
O_TEXT: int # Windows only
|
||||
O_ASYNC: int # Gnu extension if in C library
|
||||
O_DIRECT: int # Gnu extension if in C library
|
||||
O_DIRECTORY: int # Gnu extension if in C library
|
||||
O_NOFOLLOW: int # Gnu extension if in C library
|
||||
O_NOATIME: int # Gnu extension if in C library
|
||||
O_NOFOLLOW: int # Gnu extension if in C library
|
||||
O_NOATIME: int # Gnu extension if in C library
|
||||
O_PATH: int # Gnu extension if in C library
|
||||
O_TMPFILE: int # Gnu extension if in C library
|
||||
O_LARGEFILE: int # Gnu extension if in C library
|
||||
@@ -127,7 +146,7 @@ O_LARGEFILE: int # Gnu extension if in C library
|
||||
curdir: str
|
||||
pardir: str
|
||||
sep: str
|
||||
if sys.platform == 'win32':
|
||||
if sys.platform == "win32":
|
||||
altsep: str
|
||||
else:
|
||||
altsep: Optional[str]
|
||||
@@ -155,7 +174,7 @@ environ: _Environ[str]
|
||||
if sys.platform != "win32":
|
||||
environb: _Environ[bytes]
|
||||
|
||||
if sys.platform != 'win32':
|
||||
if sys.platform != "win32":
|
||||
confstr_names: Dict[str, int]
|
||||
pathconf_names: Dict[str, int]
|
||||
sysconf_names: Dict[str, int]
|
||||
@@ -181,12 +200,12 @@ if sys.platform != 'win32':
|
||||
P_NOWAIT: int
|
||||
P_NOWAITO: int
|
||||
P_WAIT: int
|
||||
if sys.platform == 'win32':
|
||||
if sys.platform == "win32":
|
||||
P_DETACH: int
|
||||
P_OVERLAY: int
|
||||
|
||||
# wait()/waitpid() options
|
||||
if sys.platform != 'win32':
|
||||
if sys.platform != "win32":
|
||||
WNOHANG: int # Unix only
|
||||
WCONTINUED: int # some Unix systems
|
||||
WUNTRACED: int # Unix only
|
||||
@@ -218,12 +237,9 @@ class stat_result:
|
||||
st_reparse_tag: int
|
||||
if sys.version_info >= (3, 5) and sys.platform == "win32":
|
||||
st_file_attributes: int
|
||||
|
||||
def __getitem__(self, i: int) -> int: ...
|
||||
|
||||
# not documented
|
||||
def __init__(self, tuple: Tuple[int, ...]) -> None: ...
|
||||
|
||||
# On some Unix systems (such as Linux), the following attributes may also
|
||||
# be available:
|
||||
st_blocks: int # number of blocks allocated for file
|
||||
@@ -258,8 +274,8 @@ if sys.version_info >= (3, 6):
|
||||
def is_file(self, *, follow_symlinks: bool = ...) -> bool: ...
|
||||
def is_symlink(self) -> bool: ...
|
||||
def stat(self, *, follow_symlinks: bool = ...) -> stat_result: ...
|
||||
|
||||
def __fspath__(self) -> AnyStr: ...
|
||||
|
||||
else:
|
||||
class DirEntry(Generic[AnyStr]):
|
||||
# This is what the scandir interator yields
|
||||
@@ -273,8 +289,7 @@ else:
|
||||
def is_symlink(self) -> bool: ...
|
||||
def stat(self, *, follow_symlinks: bool = ...) -> stat_result: ...
|
||||
|
||||
|
||||
if sys.platform != 'win32':
|
||||
if sys.platform != "win32":
|
||||
if sys.version_info >= (3, 7):
|
||||
# f_fsid was added in https://github.com/python/cpython/pull/4571
|
||||
class statvfs_result(NamedTuple): # Unix only
|
||||
@@ -302,15 +317,16 @@ if sys.platform != 'win32':
|
||||
f_flag: int
|
||||
f_namemax: int
|
||||
|
||||
|
||||
# ----- os function stubs -----
|
||||
if sys.version_info >= (3, 6):
|
||||
def fsencode(filename: Union[str, bytes, PathLike[Any]]) -> bytes: ...
|
||||
|
||||
else:
|
||||
def fsencode(filename: Union[str, bytes]) -> bytes: ...
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
def fsdecode(filename: Union[str, bytes, PathLike[Any]]) -> str: ...
|
||||
|
||||
else:
|
||||
def fsdecode(filename: Union[str, bytes]) -> str: ...
|
||||
|
||||
@@ -323,6 +339,7 @@ if sys.version_info >= (3, 6):
|
||||
def fspath(path: PathLike[AnyStr]) -> AnyStr: ...
|
||||
|
||||
def get_exec_path(env: Optional[Mapping[str, str]] = ...) -> List[str]: ...
|
||||
|
||||
# NOTE: get_exec_path(): returns List[bytes] when env not None
|
||||
def getlogin() -> str: ...
|
||||
def getpid() -> int: ...
|
||||
@@ -330,7 +347,7 @@ def getppid() -> int: ...
|
||||
def strerror(__code: int) -> str: ...
|
||||
def umask(__mask: int) -> int: ...
|
||||
|
||||
if sys.platform != 'win32':
|
||||
if sys.platform != "win32":
|
||||
# Unix only
|
||||
def ctermid() -> str: ...
|
||||
def getegid() -> int: ...
|
||||
@@ -374,21 +391,33 @@ if sys.platform != "win32":
|
||||
def getenvb(key: bytes) -> Optional[bytes]: ...
|
||||
@overload
|
||||
def getenvb(key: bytes, default: _T = ...) -> Union[bytes, _T]: ...
|
||||
|
||||
def putenv(__name: Union[bytes, str], __value: Union[bytes, str]) -> None: ...
|
||||
|
||||
if sys.platform != "win32":
|
||||
def unsetenv(__name: Union[bytes, str]) -> None: ...
|
||||
|
||||
# Return IO or TextIO
|
||||
def fdopen(fd: int, mode: str = ..., buffering: int = ..., encoding: Optional[str] = ...,
|
||||
errors: str = ..., newline: str = ..., closefd: bool = ...) -> Any: ...
|
||||
def fdopen(
|
||||
fd: int,
|
||||
mode: str = ...,
|
||||
buffering: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
errors: str = ...,
|
||||
newline: str = ...,
|
||||
closefd: bool = ...,
|
||||
) -> Any: ...
|
||||
def close(fd: int) -> None: ...
|
||||
def closerange(__fd_low: int, __fd_high: int) -> None: ...
|
||||
def device_encoding(fd: int) -> Optional[str]: ...
|
||||
def dup(__fd: int) -> int: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
def dup2(fd: int, fd2: int, inheritable: bool = ...) -> int: ...
|
||||
|
||||
else:
|
||||
def dup2(fd: int, fd2: int, inheritable: bool = ...) -> None: ...
|
||||
|
||||
def fstat(fd: int) -> stat_result: ...
|
||||
def fsync(fd: int) -> None: ...
|
||||
def lseek(__fd: int, __position: int, __how: int) -> int: ...
|
||||
@@ -396,7 +425,7 @@ def open(path: AnyPath, flags: int, mode: int = ..., *, dir_fd: Optional[int] =
|
||||
def pipe() -> Tuple[int, int]: ...
|
||||
def read(__fd: int, __length: int) -> bytes: ...
|
||||
|
||||
if sys.platform != 'win32':
|
||||
if sys.platform != "win32":
|
||||
# Unix only
|
||||
def fchmod(fd: int, mode: int) -> None: ...
|
||||
def fchown(fd: int, uid: int, gid: int) -> None: ...
|
||||
@@ -419,79 +448,89 @@ if sys.platform != 'win32':
|
||||
@overload
|
||||
def sendfile(__out_fd: int, __in_fd: int, offset: Optional[int], count: int) -> int: ...
|
||||
@overload
|
||||
def sendfile(__out_fd: int, __in_fd: int, offset: int, count: int,
|
||||
headers: Sequence[bytes] = ..., trailers: Sequence[bytes] = ..., flags: int = ...) -> int: ... # FreeBSD and Mac OS X only
|
||||
def sendfile(
|
||||
__out_fd: int,
|
||||
__in_fd: int,
|
||||
offset: int,
|
||||
count: int,
|
||||
headers: Sequence[bytes] = ...,
|
||||
trailers: Sequence[bytes] = ...,
|
||||
flags: int = ...,
|
||||
) -> int: ... # FreeBSD and Mac OS X only
|
||||
def readv(__fd: int, __buffers: Sequence[bytearray]) -> int: ...
|
||||
def writev(__fd: int, __buffers: Sequence[bytes]) -> int: ...
|
||||
|
||||
class terminal_size(Tuple[int, int]):
|
||||
columns: int
|
||||
lines: int
|
||||
def get_terminal_size(fd: int = ...) -> terminal_size: ...
|
||||
|
||||
def get_terminal_size(fd: int = ...) -> terminal_size: ...
|
||||
def get_inheritable(__fd: int) -> bool: ...
|
||||
def set_inheritable(__fd: int, __inheritable: bool) -> None: ...
|
||||
|
||||
if sys.platform != 'win32':
|
||||
if sys.platform != "win32":
|
||||
# Unix only
|
||||
def tcgetpgrp(__fd: int) -> int: ...
|
||||
def tcsetpgrp(__fd: int, __pgid: int) -> None: ...
|
||||
def ttyname(__fd: int) -> str: ...
|
||||
|
||||
def write(__fd: int, __data: bytes) -> int: ...
|
||||
def access(
|
||||
path: _FdOrAnyPath,
|
||||
mode: int,
|
||||
*,
|
||||
dir_fd: Optional[int] = ...,
|
||||
effective_ids: bool = ...,
|
||||
follow_symlinks: bool = ...,
|
||||
path: _FdOrAnyPath, mode: int, *, dir_fd: Optional[int] = ..., effective_ids: bool = ..., follow_symlinks: bool = ...,
|
||||
) -> bool: ...
|
||||
def chdir(path: _FdOrAnyPath) -> None: ...
|
||||
|
||||
if sys.platform != "win32":
|
||||
def fchdir(fd: int) -> None: ...
|
||||
|
||||
def getcwd() -> str: ...
|
||||
def getcwdb() -> bytes: ...
|
||||
def chmod(path: _FdOrAnyPath, mode: int, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> None: ...
|
||||
if sys.platform != 'win32':
|
||||
|
||||
if sys.platform != "win32":
|
||||
def chflags(path: AnyPath, 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':
|
||||
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 link(
|
||||
src: AnyPath,
|
||||
dst: AnyPath,
|
||||
*,
|
||||
src_dir_fd: Optional[int] = ...,
|
||||
dst_dir_fd: Optional[int] = ...,
|
||||
follow_symlinks: bool = ...,
|
||||
) -> None: ...
|
||||
|
||||
def link(
|
||||
src: AnyPath, dst: AnyPath, *, 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: ...
|
||||
if sys.platform != 'win32':
|
||||
|
||||
if sys.platform != "win32":
|
||||
def mkfifo(path: AnyPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ... # Unix only
|
||||
|
||||
def makedirs(name: AnyPath, mode: int = ..., exist_ok: bool = ...) -> None: ...
|
||||
|
||||
if sys.platform != "win32":
|
||||
def mknod(path: AnyPath, 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
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
def readlink(path: Union[AnyStr, PathLike[AnyStr]], *, dir_fd: Optional[int] = ...) -> AnyStr: ...
|
||||
|
||||
else:
|
||||
def readlink(path: 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: ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
class _ScandirIterator(Iterator[DirEntry[AnyStr]], ContextManager[_ScandirIterator[AnyStr]]):
|
||||
def __next__(self) -> DirEntry[AnyStr]: ...
|
||||
@@ -502,6 +541,7 @@ if sys.version_info >= (3, 7):
|
||||
def scandir(path: int) -> _ScandirIterator[str]: ...
|
||||
@overload
|
||||
def scandir(path: Union[AnyStr, PathLike[AnyStr]]) -> _ScandirIterator[AnyStr]: ...
|
||||
|
||||
elif sys.version_info >= (3, 6):
|
||||
class _ScandirIterator(Iterator[DirEntry[AnyStr]], ContextManager[_ScandirIterator[AnyStr]]):
|
||||
def __next__(self) -> DirEntry[AnyStr]: ...
|
||||
@@ -510,28 +550,29 @@ elif sys.version_info >= (3, 6):
|
||||
def scandir(path: None = ...) -> _ScandirIterator[str]: ...
|
||||
@overload
|
||||
def scandir(path: Union[AnyStr, PathLike[AnyStr]]) -> _ScandirIterator[AnyStr]: ...
|
||||
|
||||
else:
|
||||
@overload
|
||||
def scandir(path: None = ...) -> Iterator[DirEntry[str]]: ...
|
||||
@overload
|
||||
def scandir(path: AnyStr) -> Iterator[DirEntry[AnyStr]]: ...
|
||||
|
||||
def stat(path: _FdOrAnyPath, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> stat_result: ...
|
||||
|
||||
if sys.version_info < (3, 7):
|
||||
@overload
|
||||
def stat_float_times() -> bool: ...
|
||||
@overload
|
||||
def stat_float_times(__newvalue: bool) -> None: ...
|
||||
if sys.platform != 'win32':
|
||||
|
||||
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: ...
|
||||
if sys.platform != 'win32':
|
||||
|
||||
def symlink(src: AnyPath, dst: AnyPath, 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 utime(
|
||||
@@ -546,40 +587,63 @@ def utime(
|
||||
_OnError = Callable[[OSError], Any]
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
def walk(top: Union[AnyStr, PathLike[AnyStr]], topdown: bool = ...,
|
||||
onerror: Optional[_OnError] = ...,
|
||||
followlinks: bool = ...) -> Iterator[Tuple[AnyStr, List[AnyStr],
|
||||
List[AnyStr]]]: ...
|
||||
def walk(
|
||||
top: Union[AnyStr, PathLike[AnyStr]], topdown: bool = ..., onerror: Optional[_OnError] = ..., followlinks: bool = ...
|
||||
) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ...
|
||||
|
||||
else:
|
||||
def walk(top: AnyStr, topdown: bool = ..., onerror: Optional[_OnError] = ...,
|
||||
followlinks: bool = ...) -> Iterator[Tuple[AnyStr, List[AnyStr],
|
||||
List[AnyStr]]]: ...
|
||||
if sys.platform != 'win32':
|
||||
def walk(
|
||||
top: AnyStr, topdown: bool = ..., onerror: Optional[_OnError] = ..., followlinks: bool = ...
|
||||
) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ...
|
||||
|
||||
if sys.platform != "win32":
|
||||
if sys.version_info >= (3, 7):
|
||||
@overload
|
||||
def fwalk(top: Union[str, PathLike[str]] = ..., topdown: bool = ...,
|
||||
onerror: Optional[_OnError] = ..., *, follow_symlinks: bool = ...,
|
||||
dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ...
|
||||
def fwalk(
|
||||
top: Union[str, PathLike[str]] = ...,
|
||||
topdown: bool = ...,
|
||||
onerror: Optional[_OnError] = ...,
|
||||
*,
|
||||
follow_symlinks: bool = ...,
|
||||
dir_fd: Optional[int] = ...,
|
||||
) -> Iterator[Tuple[str, List[str], List[str], int]]: ...
|
||||
@overload
|
||||
def fwalk(top: bytes, topdown: bool = ...,
|
||||
onerror: Optional[_OnError] = ..., *, follow_symlinks: bool = ...,
|
||||
dir_fd: Optional[int] = ...) -> Iterator[Tuple[bytes, List[bytes], List[bytes], int]]: ...
|
||||
def fwalk(
|
||||
top: bytes,
|
||||
topdown: bool = ...,
|
||||
onerror: Optional[_OnError] = ...,
|
||||
*,
|
||||
follow_symlinks: bool = ...,
|
||||
dir_fd: Optional[int] = ...,
|
||||
) -> Iterator[Tuple[bytes, List[bytes], List[bytes], int]]: ...
|
||||
elif sys.version_info >= (3, 6):
|
||||
def fwalk(top: Union[str, PathLike[str]] = ..., topdown: bool = ...,
|
||||
onerror: Optional[_OnError] = ..., *, follow_symlinks: bool = ...,
|
||||
dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ...
|
||||
def fwalk(
|
||||
top: Union[str, PathLike[str]] = ...,
|
||||
topdown: bool = ...,
|
||||
onerror: Optional[_OnError] = ...,
|
||||
*,
|
||||
follow_symlinks: bool = ...,
|
||||
dir_fd: Optional[int] = ...,
|
||||
) -> Iterator[Tuple[str, List[str], List[str], int]]: ...
|
||||
else:
|
||||
def fwalk(top: str = ..., topdown: bool = ...,
|
||||
onerror: Optional[_OnError] = ..., *, follow_symlinks: bool = ...,
|
||||
dir_fd: Optional[int] = ...) -> Iterator[Tuple[str, List[str], List[str], int]]: ...
|
||||
def fwalk(
|
||||
top: str = ...,
|
||||
topdown: bool = ...,
|
||||
onerror: Optional[_OnError] = ...,
|
||||
*,
|
||||
follow_symlinks: bool = ...,
|
||||
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 listxattr(path: _FdOrAnyPath, *, follow_symlinks: bool = ...) -> List[str]: ...
|
||||
def removexattr(path: _FdOrAnyPath, attribute: AnyPath, *, follow_symlinks: bool = ...) -> None: ...
|
||||
def setxattr(path: _FdOrAnyPath, attribute: AnyPath, value: bytes, flags: int = ..., *,
|
||||
follow_symlinks: bool = ...) -> None: ...
|
||||
def setxattr(
|
||||
path: _FdOrAnyPath, attribute: AnyPath, 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: ...
|
||||
@@ -595,21 +659,28 @@ if sys.version_info >= (3, 6):
|
||||
# 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, ...], List[bytes], List[str], List[PathLike[Any]], List[Union[bytes, str]],
|
||||
List[Union[bytes, PathLike[Any]]], List[Union[str, PathLike[Any]]], List[Union[bytes, str, PathLike[Any]]]
|
||||
Tuple[AnyPath, ...],
|
||||
List[bytes],
|
||||
List[str],
|
||||
List[PathLike[Any]],
|
||||
List[Union[bytes, str]],
|
||||
List[Union[bytes, PathLike[Any]]],
|
||||
List[Union[str, PathLike[Any]]],
|
||||
List[Union[bytes, str, PathLike[Any]]],
|
||||
]
|
||||
else:
|
||||
_ExecVArgs = Union[Tuple[AnyPath, ...], List[bytes], List[str], List[Union[bytes, str]]]
|
||||
|
||||
_ExecEnv = Union[Mapping[bytes, Union[bytes, str]], Mapping[str, Union[bytes, str]]]
|
||||
|
||||
def execv(__path: AnyPath, __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 _exit(status: int) -> NoReturn: ...
|
||||
def kill(__pid: int, __signal: int) -> None: ...
|
||||
if sys.platform != 'win32':
|
||||
|
||||
if sys.platform != "win32":
|
||||
# Unix only
|
||||
def fork() -> int: ...
|
||||
def forkpty() -> Tuple[int, int]: ... # some flavors of Unix
|
||||
@@ -620,22 +691,26 @@ if sys.platform != 'win32':
|
||||
|
||||
class _wrap_close(_TextIOWrapper):
|
||||
def close(self) -> Optional[int]: ... # type: ignore
|
||||
def popen(cmd: str, mode: str = ..., buffering: int = ...) -> _wrap_close: ...
|
||||
|
||||
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
|
||||
|
||||
if sys.platform != "win32":
|
||||
def spawnv(mode: int, file: AnyPath, args: _ExecVArgs) -> int: ...
|
||||
def spawnve(mode: int, file: AnyPath, 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 system(command: AnyPath) -> int: ...
|
||||
def times() -> times_result: ...
|
||||
def waitpid(__pid: int, __options: int) -> Tuple[int, int]: ...
|
||||
|
||||
if sys.platform == 'win32':
|
||||
if sys.platform == "win32":
|
||||
def startfile(path: AnyPath, operation: Optional[str] = ...) -> None: ...
|
||||
|
||||
else:
|
||||
# Unix only
|
||||
def spawnlp(mode: int, file: AnyPath, arg0: AnyPath, *args: AnyPath) -> int: ...
|
||||
@@ -656,7 +731,7 @@ else:
|
||||
def WSTOPSIG(status: int) -> int: ...
|
||||
def WTERMSIG(status: int) -> int: ...
|
||||
|
||||
if sys.platform != 'win32':
|
||||
if sys.platform != "win32":
|
||||
from posix import sched_param
|
||||
def sched_get_priority_min(policy: int) -> int: ... # some flavors of Unix
|
||||
def sched_get_priority_max(policy: int) -> int: ... # some flavors of Unix
|
||||
@@ -670,14 +745,17 @@ if sys.platform != 'win32':
|
||||
def sched_getaffinity(pid: int) -> Set[int]: ... # some flavors of Unix
|
||||
|
||||
def cpu_count() -> Optional[int]: ...
|
||||
if sys.platform != 'win32':
|
||||
|
||||
if sys.platform != "win32":
|
||||
# Unix only
|
||||
def confstr(__name: Union[str, int]) -> Optional[str]: ...
|
||||
def getloadavg() -> Tuple[float, float, float]: ...
|
||||
def sysconf(__name: Union[str, int]) -> int: ...
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
if sys.platform == "linux":
|
||||
def getrandom(size: int, flags: int = ...) -> bytes: ...
|
||||
|
||||
def urandom(__size: int) -> bytes: ...
|
||||
|
||||
if sys.version_info >= (3, 7) and sys.platform != "win32":
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
# NB: path.pyi and stdlib/2 and stdlib/3 must remain consistent!
|
||||
import os
|
||||
import sys
|
||||
from typing import overload, List, Any, AnyStr, Sequence, Tuple, TypeVar, Text, Callable, Optional
|
||||
from genericpath import exists as exists
|
||||
from _typeshed import StrPath, BytesPath, AnyPath
|
||||
from typing import Any, AnyStr, Callable, List, Optional, Sequence, Text, Tuple, TypeVar, overload
|
||||
|
||||
_T = TypeVar('_T')
|
||||
from _typeshed import AnyPath, BytesPath, StrPath
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
from builtins import _PathLike
|
||||
@@ -16,7 +17,7 @@ supports_unicode_filenames: bool
|
||||
curdir: str
|
||||
pardir: str
|
||||
sep: str
|
||||
if sys.platform == 'win32':
|
||||
if sys.platform == "win32":
|
||||
altsep: str
|
||||
else:
|
||||
altsep: Optional[str]
|
||||
@@ -56,7 +57,7 @@ if sys.version_info >= (3, 6):
|
||||
def normpath(path: _PathLike[AnyStr]) -> AnyStr: ...
|
||||
@overload
|
||||
def normpath(path: AnyStr) -> AnyStr: ...
|
||||
if sys.platform == 'win32':
|
||||
if sys.platform == "win32":
|
||||
@overload
|
||||
def realpath(path: _PathLike[AnyStr]) -> AnyStr: ...
|
||||
@overload
|
||||
@@ -75,7 +76,7 @@ else:
|
||||
def expandvars(path: AnyStr) -> AnyStr: ...
|
||||
def normcase(s: AnyStr) -> AnyStr: ...
|
||||
def normpath(path: AnyStr) -> AnyStr: ...
|
||||
if sys.platform == 'win32':
|
||||
if sys.platform == "win32":
|
||||
def realpath(path: AnyStr) -> AnyStr: ...
|
||||
else:
|
||||
def realpath(filename: AnyStr) -> AnyStr: ...
|
||||
@@ -84,6 +85,7 @@ if sys.version_info >= (3, 6):
|
||||
# In reality it returns str for sequences of StrPath and bytes for sequences
|
||||
# of BytesPath, but mypy does not accept such a signature.
|
||||
def commonpath(paths: Sequence[AnyPath]) -> Any: ...
|
||||
|
||||
elif sys.version_info >= (3, 5):
|
||||
def commonpath(paths: Sequence[AnyStr]) -> AnyStr: ...
|
||||
|
||||
@@ -91,7 +93,6 @@ elif sys.version_info >= (3, 5):
|
||||
# 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: ...
|
||||
|
||||
# These return float if os.stat_float_times() == True,
|
||||
@@ -99,7 +100,6 @@ def lexists(path: AnyPath) -> bool: ...
|
||||
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: ...
|
||||
@@ -122,11 +122,13 @@ if sys.version_info < (3, 0):
|
||||
def join(__p1: bytes, __p2: Text, *p: AnyPath) -> Text: ...
|
||||
@overload
|
||||
def join(__p1: Text, *p: AnyPath) -> Text: ...
|
||||
|
||||
elif sys.version_info >= (3, 6):
|
||||
@overload
|
||||
def join(a: StrPath, *paths: StrPath) -> Text: ...
|
||||
@overload
|
||||
def join(a: BytesPath, *paths: BytesPath) -> bytes: ...
|
||||
|
||||
else:
|
||||
def join(a: AnyStr, *paths: AnyStr) -> AnyStr: ...
|
||||
|
||||
@@ -134,7 +136,6 @@ else:
|
||||
def relpath(path: BytesPath, start: Optional[BytesPath] = ...) -> bytes: ...
|
||||
@overload
|
||||
def relpath(path: StrPath, start: Optional[StrPath] = ...) -> Text: ...
|
||||
|
||||
def samefile(f1: AnyPath, f2: AnyPath) -> bool: ...
|
||||
def sameopenfile(fp1: int, fp2: int) -> bool: ...
|
||||
def samestat(s1: os.stat_result, s2: os.stat_result) -> bool: ...
|
||||
@@ -152,12 +153,13 @@ if sys.version_info >= (3, 6):
|
||||
def splitext(p: _PathLike[AnyStr]) -> Tuple[AnyStr, AnyStr]: ...
|
||||
@overload
|
||||
def splitext(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
|
||||
|
||||
else:
|
||||
def split(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
|
||||
def splitdrive(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
|
||||
def splitext(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
|
||||
|
||||
if sys.version_info < (3, 7) and sys.platform == 'win32':
|
||||
if sys.version_info < (3, 7) and sys.platform == "win32":
|
||||
def splitunc(p: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # deprecated
|
||||
|
||||
if sys.version_info < (3,):
|
||||
|
||||
Reference in New Issue
Block a user