mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-03 01:53:24 +08:00
Use sys.platform instead of comments (#2286)
This commit is contained in:
committed by
Jelle Zijlstra
parent
6192cce9d9
commit
1ae2ba0fbe
@@ -35,6 +35,9 @@ O_APPEND: int
|
||||
O_CREAT: int
|
||||
O_EXCL: int
|
||||
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
|
||||
@@ -85,39 +88,42 @@ environ: _Environ[str]
|
||||
if sys.version_info >= (3, 2):
|
||||
environb: _Environ[bytes]
|
||||
|
||||
confstr_names: Dict[str, int] # Unix only
|
||||
pathconf_names: Dict[str, int] # Unix only
|
||||
sysconf_names: Dict[str, int] # Unix only
|
||||
if sys.platform != 'win32':
|
||||
# Unix only
|
||||
confstr_names: Dict[str, int]
|
||||
pathconf_names: Dict[str, int]
|
||||
sysconf_names: Dict[str, int]
|
||||
|
||||
EX_OK: int # Unix only
|
||||
EX_USAGE: int # Unix only
|
||||
EX_DATAERR: int # Unix only
|
||||
EX_NOINPUT: int # Unix only
|
||||
EX_NOUSER: int # Unix only
|
||||
EX_NOHOST: int # Unix only
|
||||
EX_UNAVAILABLE: int # Unix only
|
||||
EX_SOFTWARE: int # Unix only
|
||||
EX_OSERR: int # Unix only
|
||||
EX_OSFILE: int # Unix only
|
||||
EX_CANTCREAT: int # Unix only
|
||||
EX_IOERR: int # Unix only
|
||||
EX_TEMPFAIL: int # Unix only
|
||||
EX_PROTOCOL: int # Unix only
|
||||
EX_NOPERM: int # Unix only
|
||||
EX_CONFIG: int # Unix only
|
||||
EX_NOTFOUND: int # Unix only
|
||||
EX_OK: int
|
||||
EX_USAGE: int
|
||||
EX_DATAERR: int
|
||||
EX_NOINPUT: int
|
||||
EX_NOUSER: int
|
||||
EX_NOHOST: int
|
||||
EX_UNAVAILABLE: int
|
||||
EX_SOFTWARE: int
|
||||
EX_OSERR: int
|
||||
EX_OSFILE: int
|
||||
EX_CANTCREAT: int
|
||||
EX_IOERR: int
|
||||
EX_TEMPFAIL: int
|
||||
EX_PROTOCOL: int
|
||||
EX_NOPERM: int
|
||||
EX_CONFIG: int
|
||||
EX_NOTFOUND: int
|
||||
|
||||
P_NOWAIT: int
|
||||
P_NOWAITO: int
|
||||
P_WAIT: int
|
||||
if sys.platform == 'win32':
|
||||
P_DETACH: int # Windows only
|
||||
P_OVERLAY: int # Windows only
|
||||
P_DETACH: int
|
||||
P_OVERLAY: int
|
||||
|
||||
# wait()/waitpid() options
|
||||
WNOHANG: int # Unix only
|
||||
WCONTINUED: int # some Unix systems
|
||||
WUNTRACED: int # Unix only
|
||||
if sys.platform != 'win32':
|
||||
WNOHANG: int # Unix only
|
||||
WCONTINUED: int # some Unix systems
|
||||
WUNTRACED: int # Unix only
|
||||
|
||||
TMP_MAX: int # Undocumented, but used by tempfile
|
||||
|
||||
@@ -132,36 +138,38 @@ _StatVFS = NamedTuple('_StatVFS', [('f_bsize', int), ('f_frsize', int), ('f_bloc
|
||||
('f_ffree', int), ('f_favail', int), ('f_flag', int),
|
||||
('f_namemax', int)])
|
||||
|
||||
def ctermid() -> str: ... # Unix only
|
||||
def getegid() -> int: ... # Unix only
|
||||
def geteuid() -> int: ... # Unix only
|
||||
def getgid() -> int: ... # Unix only
|
||||
def getgroups() -> List[int]: ... # Unix only, behaves differently on Mac
|
||||
def initgroups(username: str, gid: int) -> None: ... # Unix only
|
||||
def getlogin() -> str: ...
|
||||
def getpgid(pid: int) -> int: ... # Unix only
|
||||
def getpgrp() -> int: ... # Unix only
|
||||
def getpid() -> int: ...
|
||||
def getppid() -> int: ...
|
||||
def getresuid() -> Tuple[int, int, int]: ... # Unix only
|
||||
def getresgid() -> Tuple[int, int, int]: ... # Unix only
|
||||
def getuid() -> int: ... # Unix only
|
||||
def setegid(egid: int) -> None: ... # Unix only
|
||||
def seteuid(euid: int) -> None: ... # Unix only
|
||||
def setgid(gid: int) -> None: ... # Unix only
|
||||
def setgroups(groups: Sequence[int]) -> None: ... # Unix only
|
||||
def setpgrp() -> None: ... # Unix only
|
||||
def setpgid(pid: int, pgrp: int) -> None: ... # Unix only
|
||||
def setregid(rgid: int, egid: int) -> None: ... # Unix only
|
||||
def setresgid(rgid: int, egid: int, sgid: int) -> None: ... # Unix only
|
||||
def setresuid(ruid: int, euid: int, suid: int) -> None: ... # Unix only
|
||||
def setreuid(ruid: int, euid: int) -> None: ... # Unix only
|
||||
def getsid(pid: int) -> int: ... # Unix only
|
||||
def setsid() -> None: ... # Unix only
|
||||
def setuid(uid: int) -> None: ... # Unix only
|
||||
def strerror(code: int) -> str: ...
|
||||
def umask(mask: int) -> int: ...
|
||||
def uname() -> Tuple[str, str, str, str, str]: ... # Unix only
|
||||
|
||||
if sys.platform != 'win32':
|
||||
def ctermid() -> str: ...
|
||||
def getegid() -> int: ...
|
||||
def geteuid() -> int: ...
|
||||
def getgid() -> int: ...
|
||||
def getgroups() -> List[int]: ... # Unix only, behaves differently on Mac
|
||||
def initgroups(username: str, gid: int) -> None: ...
|
||||
def getpgid(pid: int) -> int: ...
|
||||
def getpgrp() -> int: ...
|
||||
def getresuid() -> Tuple[int, int, int]: ...
|
||||
def getresgid() -> Tuple[int, int, int]: ...
|
||||
def getuid() -> int: ...
|
||||
def setegid(egid: int) -> None: ...
|
||||
def seteuid(euid: int) -> None: ...
|
||||
def setgid(gid: int) -> None: ...
|
||||
def setgroups(groups: Sequence[int]) -> None: ...
|
||||
def setpgrp() -> None: ...
|
||||
def setpgid(pid: int, pgrp: int) -> None: ...
|
||||
def setregid(rgid: int, egid: int) -> None: ...
|
||||
def setresgid(rgid: int, egid: int, sgid: int) -> None: ...
|
||||
def setresuid(ruid: int, euid: int, suid: int) -> None: ...
|
||||
def setreuid(ruid: int, euid: int) -> None: ...
|
||||
def getsid(pid: int) -> int: ...
|
||||
def setsid() -> None: ...
|
||||
def setuid(uid: int) -> None: ...
|
||||
def uname() -> Tuple[str, str, str, str, str]: ...
|
||||
|
||||
@overload
|
||||
def getenv(key: Text) -> Optional[str]: ...
|
||||
@@ -175,47 +183,28 @@ def close(fd: int) -> None: ...
|
||||
def closerange(fd_low: int, fd_high: int) -> None: ...
|
||||
def dup(fd: int) -> int: ...
|
||||
def dup2(fd: int, fd2: int) -> None: ...
|
||||
def fchmod(fd: int, mode: int) -> None: ... # Unix only
|
||||
def fchown(fd: int, uid: int, gid: int) -> None: ... # Unix only
|
||||
def fdatasync(fd: int) -> None: ... # Unix only, not Mac
|
||||
def fpathconf(fd: int, name: Union[str, int]) -> int: ... # Unix only
|
||||
def fstat(fd: int) -> Any: ...
|
||||
def fstatvfs(fd: int) -> _StatVFS: ... # Unix only
|
||||
def fsync(fd: int) -> None: ...
|
||||
def ftruncate(fd: int, length: int) -> None: ... # Unix only
|
||||
def isatty(fd: int) -> bool: ... # Unix only
|
||||
def lseek(fd: int, pos: int, how: int) -> int: ...
|
||||
def open(file: _PathType, flags: int, mode: int = ...) -> int: ...
|
||||
def openpty() -> Tuple[int, int]: ... # some flavors of Unix
|
||||
def pipe() -> Tuple[int, int]: ...
|
||||
def read(fd: int, n: int) -> bytes: ...
|
||||
def tcgetpgrp(fd: int) -> int: ... # Unix only
|
||||
def tcsetpgrp(fd: int, pg: int) -> None: ... # Unix only
|
||||
def ttyname(fd: int) -> str: ... # Unix only
|
||||
def write(fd: int, string: bytes) -> int: ...
|
||||
def access(path: _PathType, mode: int) -> bool: ...
|
||||
def chdir(path: _PathType) -> None: ...
|
||||
def fchdir(fd: int) -> None: ...
|
||||
def getcwd() -> str: ...
|
||||
def getcwdu() -> unicode: ...
|
||||
def chflags(path: _PathType, flags: int) -> None: ... # Unix only
|
||||
def chroot(path: _PathType) -> None: ... # Unix only
|
||||
def chmod(path: _PathType, mode: int) -> None: ...
|
||||
def chown(path: _PathType, uid: int, gid: int) -> None: ... # Unix only
|
||||
def lchflags(path: _PathType, flags: int) -> None: ... # Unix only
|
||||
def lchmod(path: _PathType, mode: int) -> None: ... # Unix only
|
||||
def lchown(path: _PathType, uid: int, gid: int) -> None: ... # Unix only
|
||||
def link(src: _PathType, link_name: _PathType) -> None: ...
|
||||
def listdir(path: AnyStr) -> List[AnyStr]: ...
|
||||
def lstat(path: _PathType) -> Any: ...
|
||||
def mkfifo(path: _PathType, mode: int = ...) -> None: ... # Unix only
|
||||
def mknod(filename: _PathType, 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: _PathType, mode: int = ...) -> None: ...
|
||||
def makedirs(path: _PathType, mode: int = ...) -> None: ...
|
||||
def pathconf(path: _PathType, name: Union[str, int]) -> int: ... # Unix only
|
||||
def readlink(path: AnyStr) -> AnyStr: ...
|
||||
def remove(path: _PathType) -> None: ...
|
||||
def removedirs(path: _PathType) -> None: ...
|
||||
@@ -227,7 +216,6 @@ def stat(path: _PathType) -> Any: ...
|
||||
def stat_float_times() -> bool: ...
|
||||
@overload
|
||||
def stat_float_times(newvalue: bool) -> None: ...
|
||||
def statvfs(path: _PathType) -> _StatVFS: ... # Unix only
|
||||
def symlink(source: _PathType, link_name: _PathType) -> None: ...
|
||||
def unlink(path: _PathType) -> None: ...
|
||||
# TODO: add ns, dir_fd, follow_symlinks argument
|
||||
@@ -236,6 +224,30 @@ if sys.version_info >= (3, 0):
|
||||
else:
|
||||
def utime(path: _PathType, times: Optional[Tuple[float, float]]) -> None: ...
|
||||
|
||||
if sys.platform != 'win32':
|
||||
# Unix only
|
||||
def fchmod(fd: int, mode: int) -> None: ...
|
||||
def fchown(fd: int, uid: int, gid: int) -> None: ...
|
||||
if sys.platform != 'darwin':
|
||||
def fdatasync(fd: int) -> None: ... # Unix only, not Mac
|
||||
def fpathconf(fd: int, name: Union[str, int]) -> int: ...
|
||||
def fstatvfs(fd: int) -> _StatVFS: ...
|
||||
def ftruncate(fd: int, length: int) -> None: ...
|
||||
def isatty(fd: int) -> bool: ...
|
||||
def openpty() -> Tuple[int, int]: ... # some flavors of Unix
|
||||
def tcgetpgrp(fd: int) -> int: ...
|
||||
def tcsetpgrp(fd: int, pg: int) -> None: ...
|
||||
def ttyname(fd: int) -> str: ...
|
||||
def chflags(path: _PathType, flags: int) -> None: ...
|
||||
def chroot(path: _PathType) -> None: ...
|
||||
def chown(path: _PathType, uid: int, gid: int) -> None: ...
|
||||
def lchflags(path: _PathType, flags: int) -> None: ...
|
||||
def lchmod(path: _PathType, mode: int) -> None: ...
|
||||
def lchown(path: _PathType, uid: int, gid: int) -> None: ...
|
||||
def mkfifo(path: _PathType, mode: int = ...) -> None: ...
|
||||
def pathconf(path: _PathType, name: Union[str, int]) -> int: ...
|
||||
def statvfs(path: _PathType) -> _StatVFS: ...
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
def walk(top: Union[AnyStr, PathLike[AnyStr]], topdown: bool = ...,
|
||||
onerror: Optional[Callable[[OSError], Any]] = ...,
|
||||
@@ -264,12 +276,15 @@ def execvp(file: _PathType, args: _ExecVArgs) -> NoReturn: ...
|
||||
def execvpe(file: _PathType, args: _ExecVArgs, env: Mapping[str, str]) -> NoReturn: ...
|
||||
|
||||
def _exit(n: int) -> NoReturn: ...
|
||||
def fork() -> int: ... # Unix only
|
||||
def forkpty() -> Tuple[int, int]: ... # some flavors of Unix
|
||||
def kill(pid: int, sig: int) -> None: ...
|
||||
def killpg(pgid: int, sig: int) -> None: ... # Unix only
|
||||
def nice(increment: int) -> int: ... # Unix only
|
||||
def plock(op: int) -> None: ... # Unix only ???op is int?
|
||||
|
||||
if sys.platform != 'win32':
|
||||
# Unix only
|
||||
def fork() -> int: ...
|
||||
def forkpty() -> Tuple[int, int]: ... # some flavors of Unix
|
||||
def killpg(pgid: int, sig: int) -> None: ...
|
||||
def nice(increment: int) -> int: ...
|
||||
def plock(op: int) -> None: ... # ???op is int?
|
||||
|
||||
if sys.version_info >= (3, 0):
|
||||
class popen(_TextIOWrapper):
|
||||
@@ -286,37 +301,37 @@ else:
|
||||
def spawnl(mode: int, path: _PathType, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ...
|
||||
def spawnle(mode: int, path: _PathType, arg0: Union[bytes, Text],
|
||||
*args: Any) -> int: ... # Imprecise sig
|
||||
def spawnlp(mode: int, file: _PathType, arg0: Union[bytes, Text],
|
||||
*args: Union[bytes, Text]) -> int: ... # Unix only TODO
|
||||
def spawnlpe(mode: int, file: _PathType, arg0: Union[bytes, Text], *args: Any) -> int:
|
||||
... # Imprecise signature; Unix only TODO
|
||||
def spawnv(mode: int, path: _PathType, args: List[Union[bytes, Text]]) -> int: ...
|
||||
def spawnve(mode: int, path: _PathType, args: List[Union[bytes, Text]],
|
||||
env: Mapping[str, str]) -> int: ...
|
||||
def spawnvp(mode: int, file: _PathType, args: List[Union[bytes, Text]]) -> int: ... # Unix only
|
||||
def spawnvpe(mode: int, file: _PathType, args: List[Union[bytes, Text]],
|
||||
env: Mapping[str, str]) -> int:
|
||||
... # Unix only
|
||||
def startfile(path: _PathType, operation: Optional[str] = ...) -> None: ... # Windows only
|
||||
def system(command: _PathType) -> int: ...
|
||||
def times() -> Tuple[float, float, float, float, float]: ...
|
||||
def wait() -> Tuple[int, int]: ... # Unix only
|
||||
def waitpid(pid: int, options: int) -> Tuple[int, int]: ...
|
||||
def wait3(options: int) -> Tuple[int, int, Any]: ... # Unix only
|
||||
def wait4(pid: int, options: int) -> Tuple[int, int, Any]: ... # Unix only
|
||||
def WCOREDUMP(status: int) -> bool: ... # Unix only
|
||||
def WIFCONTINUED(status: int) -> bool: ... # Unix only
|
||||
def WIFSTOPPED(status: int) -> bool: ... # Unix only
|
||||
def WIFSIGNALED(status: int) -> bool: ... # Unix only
|
||||
def WIFEXITED(status: int) -> bool: ... # Unix only
|
||||
def WEXITSTATUS(status: int) -> int: ... # Unix only
|
||||
def WSTOPSIG(status: int) -> int: ... # Unix only
|
||||
def WTERMSIG(status: int) -> int: ... # Unix only
|
||||
def confstr(name: Union[str, int]) -> Optional[str]: ... # Unix only
|
||||
def getloadavg() -> Tuple[float, float, float]: ... # Unix only
|
||||
def sysconf(name: Union[str, int]) -> int: ... # Unix only
|
||||
def urandom(n: int) -> bytes: ...
|
||||
|
||||
if sys.platform == 'win32':
|
||||
def startfile(path: _PathType, operation: Optional[str] = ...) -> None: ...
|
||||
else:
|
||||
# Unix only
|
||||
def spawnlp(mode: int, file: _PathType, arg0: Union[bytes, Text], *args: Union[bytes, Text]) -> int: ...
|
||||
def spawnlpe(mode: int, file: _PathType, arg0: Union[bytes, Text], *args: Any) -> int: ... # Imprecise signature
|
||||
def spawnvp(mode: int, file: _PathType, args: List[Union[bytes, Text]]) -> int: ...
|
||||
def spawnvpe(mode: int, file: _PathType, 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]: ...
|
||||
def WCOREDUMP(status: int) -> bool: ...
|
||||
def WIFCONTINUED(status: int) -> bool: ...
|
||||
def WIFSTOPPED(status: int) -> bool: ...
|
||||
def WIFSIGNALED(status: int) -> bool: ...
|
||||
def WIFEXITED(status: int) -> bool: ...
|
||||
def WEXITSTATUS(status: int) -> int: ...
|
||||
def WSTOPSIG(status: int) -> int: ...
|
||||
def WTERMSIG(status: int) -> int: ...
|
||||
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, 0):
|
||||
def sched_getaffinity(id: int) -> Set[int]: ...
|
||||
if sys.version_info >= (3, 3):
|
||||
@@ -334,14 +349,15 @@ WEXITED: int
|
||||
WNOWAIT: int
|
||||
|
||||
if sys.version_info >= (3, 3):
|
||||
def sync() -> None: ... # Unix only
|
||||
if sys.platform != 'win32':
|
||||
# Unix only
|
||||
def sync() -> None: ...
|
||||
|
||||
def truncate(path: Union[_PathType, int], length: int) -> None: ... # Unix only up to version 3.4
|
||||
def truncate(path: Union[_PathType, int], length: int) -> None: ... # Unix only up to version 3.4
|
||||
|
||||
def fwalk(top: AnyStr = ..., topdown: bool = ...,
|
||||
onerror: Callable = ..., *, follow_symlinks: bool = ...,
|
||||
dir_fd: int = ...) -> Iterator[Tuple[AnyStr, List[AnyStr],
|
||||
List[AnyStr], int]]: ... # Unix only
|
||||
def fwalk(top: AnyStr = ..., topdown: bool = ...,
|
||||
onerror: Callable = ..., *, follow_symlinks: bool = ...,
|
||||
dir_fd: int = ...) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr], int]]: ...
|
||||
|
||||
terminal_size = NamedTuple('terminal_size', [('columns', int), ('lines', int)])
|
||||
def get_terminal_size(fd: int = ...) -> terminal_size: ...
|
||||
|
||||
@@ -167,7 +167,8 @@ else:
|
||||
def splitdrive(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
|
||||
def splitext(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ...
|
||||
|
||||
def splitunc(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # Windows only, deprecated
|
||||
if sys.platform == 'win32':
|
||||
def splitunc(path: AnyStr) -> Tuple[AnyStr, AnyStr]: ... # deprecated
|
||||
|
||||
if sys.version_info < (3,):
|
||||
def walk(path: AnyStr, visit: Callable[[_T, AnyStr, List[AnyStr]], Any], arg: _T) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user