Modernize syntax in various stubs (#7469)

Use `str` and `contextlib.AbstractContextManager` instead of `typing.Text` and `typing.ContextManager`.
This commit is contained in:
Alex Waygood
2022-03-09 21:23:26 +00:00
committed by GitHub
parent cdb573b398
commit 9a1f5fb06c
16 changed files with 197 additions and 202 deletions

View File

@@ -1,16 +1,14 @@
from threading import Event
from typing import Generic, Text, TypeVar
_T = TypeVar("_T", Text, bytes)
from typing import AnyStr, Generic
class PipeTimeout(IOError): ...
class BufferedPipe(Generic[_T]):
class BufferedPipe(Generic[AnyStr]):
def __init__(self) -> None: ...
def set_event(self, event: Event) -> None: ...
def feed(self, data: _T) -> None: ...
def feed(self, data: AnyStr) -> None: ...
def read_ready(self) -> bool: ...
def read(self, nbytes: int, timeout: float | None = ...) -> _T: ...
def empty(self) -> _T: ...
def read(self, nbytes: int, timeout: float | None = ...) -> AnyStr: ...
def empty(self) -> AnyStr: ...
def close(self) -> None: ...
def __len__(self) -> int: ...

View File

@@ -1,5 +1,5 @@
import sys
from typing import Protocol, Text, Union
from typing import Protocol, Union
MSG_DISCONNECT: int
MSG_IGNORE: int
@@ -109,7 +109,7 @@ else:
class _SupportsAsBytes(Protocol):
def asbytes(self) -> bytes: ...
_LikeBytes = Union[bytes, Text, _SupportsAsBytes]
_LikeBytes = Union[bytes, str, _SupportsAsBytes]
def asbytes(s: _LikeBytes) -> bytes: ...

View File

@@ -1,5 +1,5 @@
import sys
from typing import Any, Iterable, Text
from typing import Any, Iterable
from .common import _LikeBytes
@@ -27,7 +27,7 @@ class Message:
def get_int64(self) -> int: ...
def get_mpint(self) -> int: ...
def get_string(self) -> bytes: ...
def get_text(self) -> Text: ...
def get_text(self) -> str: ...
def get_binary(self) -> bytes: ...
def get_list(self) -> list[str]: ...
def add_bytes(self, b: bytes) -> Message: ...

View File

@@ -1,5 +1,5 @@
import sys
from typing import Any, Iterable, Sequence, Text, TypeVar
from typing import Any, Iterable, Sequence, TypeVar
_T = TypeVar("_T")
@@ -34,7 +34,7 @@ def byte_ord(c: int | str) -> int: ...
def byte_chr(c: int) -> bytes: ...
def byte_mask(c: int, mask: int) -> bytes: ...
def b(s: bytes | str, encoding: str = ...) -> bytes: ...
def u(s: bytes | str, encoding: str = ...) -> Text: ...
def u(s: bytes | str, encoding: str = ...) -> str: ...
def b2s(s: bytes | str) -> str: ...
def is_callable(c: Any) -> bool: ...
def next(c: Iterable[_T]) -> _T: ...

View File

@@ -1,6 +1,6 @@
from _typeshed import Self
from logging import Logger
from typing import IO, Any, Callable, Iterator, Text
from typing import IO, Any, Callable, Iterator
from paramiko.channel import Channel
from paramiko.sftp import BaseSFTP
@@ -27,35 +27,35 @@ class SFTPClient(BaseSFTP, ClosingContextManager):
def get_channel(self) -> Channel | None: ...
def listdir(self, path: str = ...) -> list[str]: ...
def listdir_attr(self, path: str = ...) -> list[SFTPAttributes]: ...
def listdir_iter(self, path: bytes | Text = ..., read_aheads: int = ...) -> Iterator[SFTPAttributes]: ...
def open(self, filename: bytes | Text, mode: str = ..., bufsize: int = ...) -> SFTPFile: ...
def listdir_iter(self, path: bytes | str = ..., read_aheads: int = ...) -> Iterator[SFTPAttributes]: ...
def open(self, filename: bytes | str, mode: str = ..., bufsize: int = ...) -> SFTPFile: ...
file = open
def remove(self, path: bytes | Text) -> None: ...
def remove(self, path: bytes | str) -> None: ...
unlink = remove
def rename(self, oldpath: bytes | Text, newpath: bytes | Text) -> None: ...
def posix_rename(self, oldpath: bytes | Text, newpath: bytes | Text) -> None: ...
def mkdir(self, path: bytes | Text, mode: int = ...) -> None: ...
def rmdir(self, path: bytes | Text) -> None: ...
def stat(self, path: bytes | Text) -> SFTPAttributes: ...
def lstat(self, path: bytes | Text) -> SFTPAttributes: ...
def symlink(self, source: bytes | Text, dest: bytes | Text) -> None: ...
def chmod(self, path: bytes | Text, mode: int) -> None: ...
def chown(self, path: bytes | Text, uid: int, gid: int) -> None: ...
def utime(self, path: bytes | Text, times: tuple[float, float] | None) -> None: ...
def truncate(self, path: bytes | Text, size: int) -> None: ...
def readlink(self, path: bytes | Text) -> Text | None: ...
def normalize(self, path: bytes | Text) -> Text: ...
def chdir(self, path: None | bytes | Text = ...) -> None: ...
def getcwd(self) -> Text | None: ...
def rename(self, oldpath: bytes | str, newpath: bytes | str) -> None: ...
def posix_rename(self, oldpath: bytes | str, newpath: bytes | str) -> None: ...
def mkdir(self, path: bytes | str, mode: int = ...) -> None: ...
def rmdir(self, path: bytes | str) -> None: ...
def stat(self, path: bytes | str) -> SFTPAttributes: ...
def lstat(self, path: bytes | str) -> SFTPAttributes: ...
def symlink(self, source: bytes | str, dest: bytes | str) -> None: ...
def chmod(self, path: bytes | str, mode: int) -> None: ...
def chown(self, path: bytes | str, uid: int, gid: int) -> None: ...
def utime(self, path: bytes | str, times: tuple[float, float] | None) -> None: ...
def truncate(self, path: bytes | str, size: int) -> None: ...
def readlink(self, path: bytes | str) -> str | None: ...
def normalize(self, path: bytes | str) -> str: ...
def chdir(self, path: None | bytes | str = ...) -> None: ...
def getcwd(self) -> str | None: ...
def putfo(
self, fl: IO[bytes], remotepath: bytes | Text, file_size: int = ..., callback: _Callback | None = ..., confirm: bool = ...
self, fl: IO[bytes], remotepath: bytes | str, file_size: int = ..., callback: _Callback | None = ..., confirm: bool = ...
) -> SFTPAttributes: ...
def put(
self, localpath: bytes | Text, remotepath: bytes | Text, callback: _Callback | None = ..., confirm: bool = ...
self, localpath: bytes | str, remotepath: bytes | str, callback: _Callback | None = ..., confirm: bool = ...
) -> SFTPAttributes: ...
def getfo(self, remotepath: bytes | Text, fl: IO[bytes], callback: _Callback | None = ..., prefetch: bool = ...) -> int: ...
def getfo(self, remotepath: bytes | str, fl: IO[bytes], callback: _Callback | None = ..., prefetch: bool = ...) -> int: ...
def get(
self, remotepath: bytes | Text, localpath: bytes | Text, callback: _Callback | None = ..., prefetch: bool = ...
self, remotepath: bytes | str, localpath: bytes | str, callback: _Callback | None = ..., prefetch: bool = ...
) -> None: ...
class SFTP(SFTPClient): ...