mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 13:34:58 +08:00
Switch to PEP-604 syntax in python2 stubs (#5915)
Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
This commit is contained in:
@@ -15,7 +15,6 @@ from typing import (
|
||||
MutableMapping,
|
||||
NamedTuple,
|
||||
NoReturn,
|
||||
Optional,
|
||||
Sequence,
|
||||
Text,
|
||||
Tuple,
|
||||
@@ -77,7 +76,7 @@ sep: str
|
||||
if sys.platform == "win32":
|
||||
altsep: str
|
||||
else:
|
||||
altsep: Optional[str]
|
||||
altsep: str | None
|
||||
extsep: str
|
||||
pathsep: str
|
||||
defpath: str
|
||||
@@ -185,11 +184,11 @@ if sys.platform != "win32":
|
||||
def uname() -> Tuple[str, str, str, str, str]: ...
|
||||
|
||||
@overload
|
||||
def getenv(key: Text) -> Optional[str]: ...
|
||||
def getenv(key: Text) -> str | None: ...
|
||||
@overload
|
||||
def getenv(key: Text, default: _T) -> Union[str, _T]: ...
|
||||
def putenv(key: Union[bytes, Text], value: Union[bytes, Text]) -> None: ...
|
||||
def unsetenv(key: Union[bytes, Text]) -> None: ...
|
||||
def getenv(key: Text, default: _T) -> str | _T: ...
|
||||
def putenv(key: bytes | Text, value: bytes | Text) -> None: ...
|
||||
def unsetenv(key: bytes | Text) -> None: ...
|
||||
def fdopen(fd: int, *args, **kwargs) -> IO[Any]: ...
|
||||
def close(fd: int) -> None: ...
|
||||
def closerange(fd_low: int, fd_high: int) -> None: ...
|
||||
@@ -201,7 +200,7 @@ def lseek(fd: int, pos: int, how: 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 write(fd: int, string: bytes | buffer) -> int: ...
|
||||
def access(path: Text, mode: int) -> bool: ...
|
||||
def chdir(path: Text) -> None: ...
|
||||
def fchdir(fd: FileDescriptorLike) -> None: ...
|
||||
@@ -231,7 +230,7 @@ def symlink(source: Text, link_name: Text) -> None: ...
|
||||
def unlink(path: Text) -> None: ...
|
||||
|
||||
# TODO: add ns, dir_fd, follow_symlinks argument
|
||||
def utime(path: Text, times: Optional[Tuple[float, float]]) -> None: ...
|
||||
def utime(path: Text, times: Tuple[float, float] | None) -> None: ...
|
||||
|
||||
if sys.platform != "win32":
|
||||
# Unix only
|
||||
@@ -239,7 +238,7 @@ if sys.platform != "win32":
|
||||
def fchown(fd: int, uid: int, gid: int) -> None: ...
|
||||
if sys.platform != "darwin":
|
||||
def fdatasync(fd: FileDescriptorLike) -> None: ... # Unix only, not Mac
|
||||
def fpathconf(fd: int, name: Union[str, int]) -> int: ...
|
||||
def fpathconf(fd: int, name: str | int) -> int: ...
|
||||
def fstatvfs(fd: int) -> _StatVFS: ...
|
||||
def ftruncate(fd: int, length: int) -> None: ...
|
||||
def isatty(fd: int) -> bool: ...
|
||||
@@ -254,21 +253,21 @@ if sys.platform != "win32":
|
||||
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 pathconf(path: Text, name: str | int) -> int: ...
|
||||
def statvfs(path: Text) -> _StatVFS: ...
|
||||
|
||||
def walk(
|
||||
top: AnyStr, topdown: bool = ..., onerror: Optional[Callable[[OSError], Any]] = ..., followlinks: bool = ...
|
||||
top: AnyStr, topdown: bool = ..., onerror: Callable[[OSError], Any] | None = ..., followlinks: bool = ...
|
||||
) -> Iterator[Tuple[AnyStr, List[AnyStr], List[AnyStr]]]: ...
|
||||
def abort() -> NoReturn: ...
|
||||
|
||||
# These are defined as execl(file, *args) but the first *arg is mandatory.
|
||||
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: ...
|
||||
def execl(file: Text, __arg0: bytes | Text, *args: bytes | Text) -> NoReturn: ...
|
||||
def execlp(file: Text, __arg0: bytes | Text, *args: bytes | Text) -> NoReturn: ...
|
||||
|
||||
# These are: execle(file, *args, env) but env is pulled from the last element of the args.
|
||||
def execle(file: Text, __arg0: Union[bytes, Text], *args: Any) -> NoReturn: ...
|
||||
def execlpe(file: Text, __arg0: Union[bytes, Text], *args: Any) -> NoReturn: ...
|
||||
def execle(file: Text, __arg0: bytes | Text, *args: Any) -> NoReturn: ...
|
||||
def execlpe(file: Text, __arg0: 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.
|
||||
@@ -293,24 +292,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: 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 spawnl(mode: int, path: Text, arg0: bytes | Text, *args: bytes | Text) -> int: ...
|
||||
def spawnle(mode: int, path: Text, arg0: bytes | Text, *args: Any) -> int: ... # Imprecise sig
|
||||
def spawnv(mode: int, path: Text, args: List[bytes | Text]) -> int: ...
|
||||
def spawnve(mode: int, path: Text, args: List[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: Text, operation: Optional[str] = ...) -> None: ...
|
||||
def startfile(path: Text, operation: str | None = ...) -> None: ...
|
||||
|
||||
else:
|
||||
# Unix only
|
||||
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 spawnlp(mode: int, file: Text, arg0: bytes | Text, *args: bytes | Text) -> int: ...
|
||||
def spawnlpe(mode: int, file: Text, arg0: bytes | Text, *args: Any) -> int: ... # Imprecise signature
|
||||
def spawnvp(mode: int, file: Text, args: List[bytes | Text]) -> int: ...
|
||||
def spawnvpe(mode: int, file: Text, args: List[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]: ...
|
||||
@@ -322,9 +321,9 @@ else:
|
||||
def WEXITSTATUS(status: int) -> int: ...
|
||||
def WSTOPSIG(status: int) -> int: ...
|
||||
def WTERMSIG(status: int) -> int: ...
|
||||
def confstr(name: Union[str, int]) -> Optional[str]: ...
|
||||
def confstr(name: str | int) -> str | None: ...
|
||||
def getloadavg() -> Tuple[float, float, float]: ...
|
||||
def sysconf(name: Union[str, int]) -> int: ...
|
||||
def sysconf(name: str | int) -> int: ...
|
||||
|
||||
def tmpfile() -> IO[Any]: ...
|
||||
def tmpnam() -> str: ...
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import os
|
||||
import sys
|
||||
from typing import Any, AnyStr, Callable, List, Optional, Sequence, Text, Tuple, TypeVar, overload
|
||||
from typing import Any, AnyStr, Callable, List, Sequence, Text, Tuple, TypeVar, overload
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
@@ -13,7 +13,7 @@ sep: str
|
||||
if sys.platform == "win32":
|
||||
altsep: str
|
||||
else:
|
||||
altsep: Optional[str]
|
||||
altsep: str | None
|
||||
extsep: str
|
||||
pathsep: str
|
||||
defpath: str
|
||||
@@ -68,9 +68,9 @@ def join(__p1: bytes, __p2: Text, *p: Text) -> Text: ...
|
||||
@overload
|
||||
def join(__p1: Text, *p: Text) -> Text: ...
|
||||
@overload
|
||||
def relpath(path: str, start: Optional[str] = ...) -> str: ...
|
||||
def relpath(path: str, start: str | None = ...) -> str: ...
|
||||
@overload
|
||||
def relpath(path: Text, start: Optional[Text] = ...) -> Text: ...
|
||||
def relpath(path: Text, start: Text | None = ...) -> 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: ...
|
||||
|
||||
Reference in New Issue
Block a user