Big diff: Use new "|" union syntax (#5872)

This commit is contained in:
Akuli
2021-08-08 12:05:21 +03:00
committed by GitHub
parent b9adb7a874
commit ee487304d7
578 changed files with 8080 additions and 8966 deletions

View File

@@ -11,13 +11,11 @@ from typing import (
Iterable,
Iterator,
List,
Optional,
Protocol,
TextIO,
Tuple,
Type,
TypeVar,
Union,
overload,
)
from typing_extensions import Literal
@@ -80,8 +78,8 @@ def decode(obj: str, encoding: Literal["rot13", "rot_13"] = ..., errors: str = .
@overload
def decode(obj: bytes, encoding: str = ..., errors: str = ...) -> str: ...
def lookup(__encoding: str) -> CodecInfo: ...
def utf_16_be_decode(__data: bytes, __errors: Optional[str] = ..., __final: bool = ...) -> Tuple[str, int]: ... # undocumented
def utf_16_be_encode(__str: str, __errors: Optional[str] = ...) -> Tuple[bytes, int]: ... # undocumented
def utf_16_be_decode(__data: bytes, __errors: str | None = ..., __final: bool = ...) -> Tuple[str, int]: ... # undocumented
def utf_16_be_encode(__str: str, __errors: str | None = ...) -> Tuple[bytes, int]: ... # undocumented
class CodecInfo(Tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):
@property
@@ -101,13 +99,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: ...
@@ -116,16 +114,16 @@ 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[bytes], data_encoding: str, file_encoding: Optional[str] = ..., errors: str = ...) -> StreamRecoder: ...
def EncodedFile(file: IO[bytes], data_encoding: str, file_encoding: str | None = ..., errors: str = ...) -> StreamRecoder: ...
def iterencode(iterator: Iterable[str], encoding: str, errors: str = ...) -> Generator[bytes, None, None]: ...
def iterdecode(iterator: Iterable[bytes], encoding: str, errors: str = ...) -> Generator[str, None, None]: ...
if sys.version_info >= (3, 10):
def unregister(__search_function: Callable[[str], Optional[CodecInfo]]) -> None: ...
def unregister(__search_function: Callable[[str], CodecInfo | None]) -> None: ...
BOM: bytes
BOM_BE: bytes
@@ -141,13 +139,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.
@@ -162,8 +160,8 @@ class IncrementalEncoder:
def encode(self, input: str, final: bool = ...) -> bytes: ...
def reset(self) -> None: ...
# documentation says int but str is needed for the subclass.
def getstate(self) -> Union[int, str]: ...
def setstate(self, state: Union[int, str]) -> None: ...
def getstate(self) -> int | str: ...
def setstate(self, state: int | str) -> None: ...
class IncrementalDecoder:
errors: str
@@ -198,22 +196,18 @@ class StreamWriter(Codec):
def writelines(self, list: Iterable[str]) -> None: ...
def reset(self) -> None: ...
def __enter__(self: Self) -> Self: ...
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: ...
class StreamReader(Codec):
errors: str
def __init__(self, stream: IO[bytes], errors: str = ...) -> None: ...
def read(self, size: int = ..., chars: int = ..., firstline: bool = ...) -> str: ...
def readline(self, size: Optional[int] = ..., keepends: bool = ...) -> str: ...
def readlines(self, sizehint: Optional[int] = ..., keepends: bool = ...) -> List[str]: ...
def readline(self, size: int | None = ..., keepends: bool = ...) -> str: ...
def readlines(self, sizehint: int | None = ..., keepends: bool = ...) -> List[str]: ...
def reset(self) -> None: ...
def __enter__(self: Self) -> Self: ...
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[str]: ...
def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ...
@@ -224,8 +218,8 @@ _T = TypeVar("_T", bound=StreamReaderWriter)
class StreamReaderWriter(TextIO):
def __init__(self, stream: IO[bytes], Reader: _StreamReader, Writer: _StreamWriter, errors: str = ...) -> None: ...
def read(self, size: int = ...) -> str: ...
def readline(self, size: Optional[int] = ...) -> str: ...
def readlines(self, sizehint: Optional[int] = ...) -> List[str]: ...
def readline(self, size: int | None = ...) -> str: ...
def readlines(self, sizehint: int | None = ...) -> List[str]: ...
def __next__(self) -> str: ...
def __iter__(self: _T) -> _T: ...
# This actually returns None, but that's incompatible with the supertype
@@ -235,9 +229,7 @@ class StreamReaderWriter(TextIO):
# Same as write()
def seek(self, offset: int, whence: int = ...) -> int: ...
def __enter__(self: Self) -> Self: ...
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__.
@@ -246,7 +238,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: ...
@@ -264,8 +256,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: ...
@@ -273,9 +265,7 @@ class StreamRecoder(BinaryIO):
def reset(self) -> None: ...
def __getattr__(self, name: str) -> Any: ...
def __enter__(self: Self) -> Self: ...
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: ...
@@ -284,7 +274,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: ...