mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
Merge pull request #1054 from euresti/path_type
Use Union[bytes, Text] for paths in os.py
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
from typing import (
|
||||
List, Tuple, Union, Sequence, Mapping, IO, Any, Optional, AnyStr, Iterator,
|
||||
Dict, MutableMapping, NamedTuple, overload
|
||||
Dict, MutableMapping, NamedTuple, overload, Text
|
||||
)
|
||||
from . import path
|
||||
from mypy_extensions import NoReturn
|
||||
@@ -93,6 +93,7 @@ WCONTINUED = 0 # some Unix systems
|
||||
WUNTRACED = 0 # Unix only
|
||||
|
||||
TMP_MAX = 0
|
||||
_PathType = Union[bytes, Text]
|
||||
_StatVFS = NamedTuple('_StatVFS', [('f_bsize', int), ('f_frsize', int), ('f_blocks', int),
|
||||
('f_bfree', int), ('f_bavail', int), ('f_files', int),
|
||||
('f_ffree', int), ('f_favail', int), ('f_flag', int),
|
||||
@@ -144,7 +145,7 @@ def fsync(fd: int) -> None: ...
|
||||
def ftruncate(fd: int, length: int) -> None: ...
|
||||
def isatty(fd: int) -> bool: ...
|
||||
def lseek(fd: int, pos: int, how: int) -> None: ...
|
||||
def open(file: unicode, flags: int, mode: int = ...) -> int: ...
|
||||
def open(file: _PathType, flags: int, mode: int = ...) -> int: ...
|
||||
def openpty() -> Tuple[int, int]: ...
|
||||
def pipe() -> Tuple[int, int]: ...
|
||||
def read(fd: int, n: int) -> str: ...
|
||||
@@ -152,58 +153,58 @@ def tcgetpgrp(fd: int) -> int: ...
|
||||
def tcsetpgrp(fd: int, pg: int) -> None: ...
|
||||
def ttyname(fd: int) -> str: ...
|
||||
def write(fd: int, str: str) -> int: ...
|
||||
def access(path: unicode, mode: int) -> bool: ...
|
||||
def access(path: _PathType, mode: int) -> bool: ...
|
||||
def fpathconf(fd: int, name: str) -> None: ...
|
||||
def chdir(path: unicode) -> None: ...
|
||||
def chdir(path: _PathType) -> None: ...
|
||||
def fchdir(fd: int) -> None: ...
|
||||
def getcwd() -> str: ...
|
||||
def getcwdu() -> unicode: ...
|
||||
def chflags(path: unicode, flags: int) -> None: ...
|
||||
def chroot(path: unicode) -> None: ...
|
||||
def chmod(path: unicode, mode: int) -> None: ...
|
||||
def chown(path: unicode, uid: int, gid: int) -> None: ...
|
||||
def lchflags(path: unicode, flags: int) -> None: ...
|
||||
def lchmod(path: unicode, uid: int, gid: int) -> None: ...
|
||||
def lchown(path: unicode, uid: int, gid: int) -> None: ...
|
||||
def link(source: unicode, link_name: unicode) -> None: ...
|
||||
def chflags(path: _PathType, flags: int) -> None: ...
|
||||
def chroot(path: _PathType) -> None: ...
|
||||
def chmod(path: _PathType, mode: int) -> None: ...
|
||||
def chown(path: _PathType, uid: int, gid: int) -> None: ...
|
||||
def lchflags(path: _PathType, flags: int) -> None: ...
|
||||
def lchmod(path: _PathType, uid: int, gid: int) -> None: ...
|
||||
def lchown(path: _PathType, uid: int, gid: int) -> None: ...
|
||||
def link(source: _PathType, link_name: _PathType) -> None: ...
|
||||
def listdir(path: AnyStr) -> List[AnyStr]: ...
|
||||
def lstat(path: unicode) -> Any: ...
|
||||
def mkfifo(path: unicode, mode: int = ...) -> None: ...
|
||||
def mknod(filename: unicode, mode: int = ..., device: int = ...) -> None: ...
|
||||
def lstat(path: _PathType) -> Any: ...
|
||||
def mkfifo(path: _PathType, mode: int = ...) -> None: ...
|
||||
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: unicode, mode: int = ...) -> None: ...
|
||||
def makedirs(path: unicode, mode: int = ...) -> None: ...
|
||||
def pathconf(path: unicode, name: str) -> str: ...
|
||||
def mkdir(path: _PathType, mode: int = ...) -> None: ...
|
||||
def makedirs(path: _PathType, mode: int = ...) -> None: ...
|
||||
def pathconf(path: _PathType, name: str) -> str: ...
|
||||
def readlink(path: AnyStr) -> AnyStr: ...
|
||||
def remove(path: unicode) -> None: ...
|
||||
def removedirs(path: unicode) -> None: ...
|
||||
def rename(src: unicode, dst: unicode) -> None: ...
|
||||
def renames(old: unicode, new: unicode) -> None: ...
|
||||
def rmdir(path: unicode) -> None: ...
|
||||
def stat(path: unicode) -> Any: ...
|
||||
def remove(path: _PathType) -> None: ...
|
||||
def removedirs(path: _PathType) -> None: ...
|
||||
def rename(src: _PathType, dst: _PathType) -> None: ...
|
||||
def renames(old: _PathType, new: _PathType) -> None: ...
|
||||
def rmdir(path: _PathType) -> None: ...
|
||||
def stat(path: _PathType) -> Any: ...
|
||||
@overload
|
||||
def stat_float_times(newvalue: bool = ...) -> None: ...
|
||||
@overload
|
||||
def stat_float_times() -> bool: ...
|
||||
def statvfs(path: unicode) -> _StatVFS: ...
|
||||
def symlink(source: unicode, link_name: unicode) -> None: ...
|
||||
def unlink(path: unicode) -> None: ...
|
||||
def utime(path: unicode, times: Optional[Tuple[int, int]]) -> None: ...
|
||||
def statvfs(path: _PathType) -> _StatVFS: ...
|
||||
def symlink(source: _PathType, link_name: _PathType) -> None: ...
|
||||
def unlink(path: _PathType) -> None: ...
|
||||
def utime(path: _PathType, times: Optional[Tuple[int, int]]) -> None: ...
|
||||
def walk(top: AnyStr, topdown: bool = ..., onerror: Any = ...,
|
||||
followlinks: bool = ...) -> Iterator[Tuple[AnyStr, List[AnyStr],
|
||||
List[AnyStr]]]: ...
|
||||
|
||||
def abort() -> None: ...
|
||||
def execl(file: AnyStr, *args) -> None: ...
|
||||
def execle(file: AnyStr, *args) -> None: ...
|
||||
def execlp(file: AnyStr, *args) -> None: ...
|
||||
def execlpe(file: AnyStr, *args) -> None: ...
|
||||
def execv(path: AnyStr, args: Union[Tuple[AnyStr], List[AnyStr]]) -> None: ...
|
||||
def execve(path: AnyStr, args: Union[Tuple[AnyStr], List[AnyStr]], env: Mapping[AnyStr, AnyStr]) -> None: ...
|
||||
def execvp(file: AnyStr, args: Union[Tuple[AnyStr], List[AnyStr]]) -> None: ...
|
||||
def execvpe(file: AnyStr, args: Union[Tuple[AnyStr], List[AnyStr]], env: Mapping[AnyStr, AnyStr]) -> None: ...
|
||||
def execl(file: _PathType, *args) -> None: ...
|
||||
def execle(file: _PathType, *args) -> None: ...
|
||||
def execlp(file: _PathType, *args) -> None: ...
|
||||
def execlpe(file: _PathType, *args) -> None: ...
|
||||
def execv(path: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]]) -> None: ...
|
||||
def execve(path: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]], env: Mapping[str, str]) -> None: ...
|
||||
def execvp(file: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]]) -> None: ...
|
||||
def execvpe(file: _PathType, args: Union[Tuple[Union[bytes, Text]], List[Union[bytes, Text]]], env: Mapping[str, str]) -> None: ...
|
||||
def _exit(n: int) -> NoReturn: ...
|
||||
def fork() -> int: ...
|
||||
def forkpty() -> Tuple[int, int]: ...
|
||||
@@ -216,22 +217,22 @@ 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: AnyStr, arg0: AnyStr, *args: AnyStr) -> int: ...
|
||||
def spawnle(mode: int, path: AnyStr, arg0: AnyStr,
|
||||
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: AnyStr, arg0: AnyStr,
|
||||
*args: AnyStr) -> int: ... # Unix only TODO
|
||||
def spawnlpe(mode: int, file: AnyStr, arg0: AnyStr, *args: Any) -> int:
|
||||
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: AnyStr, args: List[AnyStr]) -> int: ...
|
||||
def spawnve(mode: int, path: AnyStr, args: List[AnyStr],
|
||||
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: AnyStr, args: List[AnyStr]) -> int: ... # Unix only
|
||||
def spawnvpe(mode: int, file: AnyStr, args: List[AnyStr],
|
||||
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: unicode, operation: str = ...) -> None: ... # Windows only
|
||||
def system(command: unicode) -> int: ...
|
||||
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]: ...
|
||||
|
||||
Reference in New Issue
Block a user