Switch to PEP-604 syntax in python2 stubs (#5915)

Signed-off-by: oleg.hoefling <oleg.hoefling@gmail.com>
This commit is contained in:
Oleg Höfling
2021-08-14 11:12:30 +02:00
committed by GitHub
parent 431c4f7fc1
commit ff63953188
235 changed files with 2473 additions and 2768 deletions

View File

@@ -9,7 +9,6 @@ from typing import (
Iterable,
Iterator,
List,
Optional,
Protocol,
Text,
TextIO,
@@ -83,9 +82,9 @@ def decode(obj: str, encoding: Literal["rot13", "rot_13"] = ..., errors: str = .
def decode(obj: _Encoded, encoding: str = ..., errors: str = ...) -> _Decoded: ...
def lookup(__encoding: str) -> CodecInfo: ...
def utf_16_be_decode(
__data: _Encoded, __errors: Optional[str] = ..., __final: bool = ...
__data: _Encoded, __errors: str | None = ..., __final: bool = ...
) -> Tuple[_Decoded, int]: ... # undocumented
def utf_16_be_encode(__str: _Decoded, __errors: Optional[str] = ...) -> Tuple[_Encoded, int]: ... # undocumented
def utf_16_be_encode(__str: _Decoded, __errors: str | None = ...) -> Tuple[_Encoded, int]: ... # undocumented
class CodecInfo(Tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):
@property
@@ -105,13 +104,13 @@ class CodecInfo(Tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):
cls,
encode: _Encoder,
decode: _Decoder,
streamreader: Optional[_StreamReader] = ...,
streamwriter: Optional[_StreamWriter] = ...,
incrementalencoder: Optional[_IncrementalEncoder] = ...,
incrementaldecoder: Optional[_IncrementalDecoder] = ...,
name: Optional[str] = ...,
streamreader: _StreamReader | None = ...,
streamwriter: _StreamWriter | None = ...,
incrementalencoder: _IncrementalEncoder | None = ...,
incrementaldecoder: _IncrementalDecoder | None = ...,
name: str | None = ...,
*,
_is_text_encoding: Optional[bool] = ...,
_is_text_encoding: bool | None = ...,
) -> CodecInfo: ...
def getencoder(encoding: str) -> _Encoder: ...
@@ -120,13 +119,11 @@ def getincrementalencoder(encoding: str) -> _IncrementalEncoder: ...
def getincrementaldecoder(encoding: str) -> _IncrementalDecoder: ...
def getreader(encoding: str) -> _StreamReader: ...
def getwriter(encoding: str) -> _StreamWriter: ...
def register(__search_function: Callable[[str], Optional[CodecInfo]]) -> None: ...
def register(__search_function: Callable[[str], CodecInfo | None]) -> None: ...
def open(
filename: str, mode: str = ..., encoding: Optional[str] = ..., errors: str = ..., buffering: int = ...
filename: str, mode: str = ..., encoding: str | None = ..., errors: str = ..., buffering: int = ...
) -> StreamReaderWriter: ...
def EncodedFile(
file: IO[_Encoded], data_encoding: str, file_encoding: Optional[str] = ..., errors: str = ...
) -> StreamRecoder: ...
def EncodedFile(file: IO[_Encoded], data_encoding: str, file_encoding: str | None = ..., errors: str = ...) -> StreamRecoder: ...
def iterencode(iterator: Iterable[_Decoded], encoding: str, errors: str = ...) -> Generator[_Encoded, None, None]: ...
def iterdecode(iterator: Iterable[_Encoded], encoding: str, errors: str = ...) -> Generator[_Decoded, None, None]: ...
@@ -144,13 +141,13 @@ BOM_UTF32_LE: bytes
# It is expected that different actions be taken depending on which of the
# three subclasses of `UnicodeError` is actually ...ed. However, the Union
# is still needed for at least one of the cases.
def register_error(__errors: str, __handler: Callable[[UnicodeError], Tuple[Union[str, bytes], int]]) -> None: ...
def lookup_error(__name: str) -> Callable[[UnicodeError], Tuple[Union[str, bytes], int]]: ...
def strict_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ...
def replace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ...
def ignore_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ...
def xmlcharrefreplace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ...
def backslashreplace_errors(exception: UnicodeError) -> Tuple[Union[str, bytes], int]: ...
def register_error(__errors: str, __handler: Callable[[UnicodeError], Tuple[str | bytes, int]]) -> None: ...
def lookup_error(__name: str) -> Callable[[UnicodeError], Tuple[str | bytes, int]]: ...
def strict_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ...
def replace_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ...
def ignore_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ...
def xmlcharrefreplace_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ...
def backslashreplace_errors(exception: UnicodeError) -> Tuple[str | bytes, int]: ...
class Codec:
# These are sort of @abstractmethod but sort of not.
@@ -165,8 +162,8 @@ class IncrementalEncoder:
def encode(self, input: _Decoded, final: bool = ...) -> _Encoded: ...
def reset(self) -> None: ...
# documentation says int but str is needed for the subclass.
def getstate(self) -> Union[int, _Decoded]: ...
def setstate(self, state: Union[int, _Decoded]) -> None: ...
def getstate(self) -> int | _Decoded: ...
def setstate(self, state: int | _Decoded) -> None: ...
class IncrementalDecoder:
errors: str
@@ -203,9 +200,7 @@ class StreamWriter(Codec):
def writelines(self, list: Iterable[_Decoded]) -> None: ...
def reset(self) -> None: ...
def __enter__(self: _SW) -> _SW: ...
def __exit__(
self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType]
) -> None: ...
def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ...
def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ...
_SR = TypeVar("_SR", bound=StreamReader)
@@ -214,13 +209,11 @@ class StreamReader(Codec):
errors: str
def __init__(self, stream: IO[_Encoded], errors: str = ...) -> None: ...
def read(self, size: int = ..., chars: int = ..., firstline: bool = ...) -> _Decoded: ...
def readline(self, size: Optional[int] = ..., keepends: bool = ...) -> _Decoded: ...
def readlines(self, sizehint: Optional[int] = ..., keepends: bool = ...) -> List[_Decoded]: ...
def readline(self, size: int | None = ..., keepends: bool = ...) -> _Decoded: ...
def readlines(self, sizehint: int | None = ..., keepends: bool = ...) -> List[_Decoded]: ...
def reset(self) -> None: ...
def __enter__(self: _SR) -> _SR: ...
def __exit__(
self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType]
) -> None: ...
def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ...
def __iter__(self) -> Iterator[_Decoded]: ...
def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ...
@@ -231,8 +224,8 @@ _T = TypeVar("_T", bound=StreamReaderWriter)
class StreamReaderWriter(TextIO):
def __init__(self, stream: IO[_Encoded], Reader: _StreamReader, Writer: _StreamWriter, errors: str = ...) -> None: ...
def read(self, size: int = ...) -> _Decoded: ...
def readline(self, size: Optional[int] = ...) -> _Decoded: ...
def readlines(self, sizehint: Optional[int] = ...) -> List[_Decoded]: ...
def readline(self, size: int | None = ...) -> _Decoded: ...
def readlines(self, sizehint: int | None = ...) -> List[_Decoded]: ...
def next(self) -> Text: ...
def __iter__(self: _T) -> _T: ...
# This actually returns None, but that's incompatible with the supertype
@@ -242,9 +235,7 @@ class StreamReaderWriter(TextIO):
# Same as write()
def seek(self, offset: int, whence: int = ...) -> int: ...
def __enter__(self: _T) -> _T: ...
def __exit__(
self, typ: Optional[Type[BaseException]], exc: Optional[BaseException], tb: Optional[types.TracebackType]
) -> None: ...
def __exit__(self, typ: Type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ...
def __getattr__(self, name: str) -> Any: ...
# These methods don't actually exist directly, but they are needed to satisfy the TextIO
# interface. At runtime, they are delegated through __getattr__.
@@ -253,7 +244,7 @@ class StreamReaderWriter(TextIO):
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def readable(self) -> bool: ...
def truncate(self, size: Optional[int] = ...) -> int: ...
def truncate(self, size: int | None = ...) -> int: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def writable(self) -> bool: ...
@@ -271,8 +262,8 @@ class StreamRecoder(BinaryIO):
errors: str = ...,
) -> None: ...
def read(self, size: int = ...) -> bytes: ...
def readline(self, size: Optional[int] = ...) -> bytes: ...
def readlines(self, sizehint: Optional[int] = ...) -> List[bytes]: ...
def readline(self, size: int | None = ...) -> bytes: ...
def readlines(self, sizehint: int | None = ...) -> List[bytes]: ...
def next(self) -> bytes: ...
def __iter__(self: _SRT) -> _SRT: ...
def write(self, data: bytes) -> int: ...
@@ -280,9 +271,7 @@ class StreamRecoder(BinaryIO):
def reset(self) -> None: ...
def __getattr__(self, name: str) -> Any: ...
def __enter__(self: _SRT) -> _SRT: ...
def __exit__(
self, type: Optional[Type[BaseException]], value: Optional[BaseException], tb: Optional[types.TracebackType]
) -> None: ...
def __exit__(self, type: Type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ...
# These methods don't actually exist directly, but they are needed to satisfy the BinaryIO
# interface. At runtime, they are delegated through __getattr__.
def seek(self, offset: int, whence: int = ...) -> int: ...
@@ -291,7 +280,7 @@ class StreamRecoder(BinaryIO):
def flush(self) -> None: ...
def isatty(self) -> bool: ...
def readable(self) -> bool: ...
def truncate(self, size: Optional[int] = ...) -> int: ...
def truncate(self, size: int | None = ...) -> int: ...
def seekable(self) -> bool: ...
def tell(self) -> int: ...
def writable(self) -> bool: ...