mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-25 04:16:44 +08:00
stdlib: add argument default values (#9501)
This commit is contained in:
@@ -112,13 +112,13 @@ class CodecInfo(tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):
|
||||
cls: type[Self],
|
||||
encode: _Encoder,
|
||||
decode: _Decoder,
|
||||
streamreader: _StreamReader | None = ...,
|
||||
streamwriter: _StreamWriter | None = ...,
|
||||
incrementalencoder: _IncrementalEncoder | None = ...,
|
||||
incrementaldecoder: _IncrementalDecoder | None = ...,
|
||||
name: str | None = ...,
|
||||
streamreader: _StreamReader | None = None,
|
||||
streamwriter: _StreamWriter | None = None,
|
||||
incrementalencoder: _IncrementalEncoder | None = None,
|
||||
incrementaldecoder: _IncrementalDecoder | None = None,
|
||||
name: str | None = None,
|
||||
*,
|
||||
_is_text_encoding: bool | None = ...,
|
||||
_is_text_encoding: bool | None = None,
|
||||
) -> Self: ...
|
||||
|
||||
def getencoder(encoding: str) -> _Encoder: ...
|
||||
@@ -128,11 +128,11 @@ def getincrementaldecoder(encoding: str) -> _IncrementalDecoder: ...
|
||||
def getreader(encoding: str) -> _StreamReader: ...
|
||||
def getwriter(encoding: str) -> _StreamWriter: ...
|
||||
def open(
|
||||
filename: str, mode: str = ..., encoding: str | None = ..., errors: str = ..., buffering: int = ...
|
||||
filename: str, mode: str = "r", encoding: str | None = None, errors: str = "strict", buffering: int = -1
|
||||
) -> StreamReaderWriter: ...
|
||||
def EncodedFile(file: _Stream, 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]: ...
|
||||
def EncodedFile(file: _Stream, data_encoding: str, file_encoding: str | None = None, errors: str = "strict") -> StreamRecoder: ...
|
||||
def iterencode(iterator: Iterable[str], encoding: str, errors: str = "strict") -> Generator[bytes, None, None]: ...
|
||||
def iterdecode(iterator: Iterable[bytes], encoding: str, errors: str = "strict") -> Generator[str, None, None]: ...
|
||||
|
||||
BOM: Literal[b"\xff\xfe", b"\xfe\xff"] # depends on `sys.byteorder`
|
||||
BOM_BE: Literal[b"\xfe\xff"]
|
||||
@@ -155,14 +155,14 @@ def namereplace_errors(exception: UnicodeError) -> tuple[str | bytes, int]: ...
|
||||
class Codec:
|
||||
# These are sort of @abstractmethod but sort of not.
|
||||
# The StreamReader and StreamWriter subclasses only implement one.
|
||||
def encode(self, input: str, errors: str = ...) -> tuple[bytes, int]: ...
|
||||
def decode(self, input: bytes, errors: str = ...) -> tuple[str, int]: ...
|
||||
def encode(self, input: str, errors: str = "strict") -> tuple[bytes, int]: ...
|
||||
def decode(self, input: bytes, errors: str = "strict") -> tuple[str, int]: ...
|
||||
|
||||
class IncrementalEncoder:
|
||||
errors: str
|
||||
def __init__(self, errors: str = ...) -> None: ...
|
||||
def __init__(self, errors: str = "strict") -> None: ...
|
||||
@abstractmethod
|
||||
def encode(self, input: str, final: bool = ...) -> bytes: ...
|
||||
def encode(self, input: str, final: bool = False) -> bytes: ...
|
||||
def reset(self) -> None: ...
|
||||
# documentation says int but str is needed for the subclass.
|
||||
def getstate(self) -> int | str: ...
|
||||
@@ -170,9 +170,9 @@ class IncrementalEncoder:
|
||||
|
||||
class IncrementalDecoder:
|
||||
errors: str
|
||||
def __init__(self, errors: str = ...) -> None: ...
|
||||
def __init__(self, errors: str = "strict") -> None: ...
|
||||
@abstractmethod
|
||||
def decode(self, input: ReadableBuffer, final: bool = ...) -> str: ...
|
||||
def decode(self, input: ReadableBuffer, final: bool = False) -> str: ...
|
||||
def reset(self) -> None: ...
|
||||
def getstate(self) -> tuple[bytes, int]: ...
|
||||
def setstate(self, state: tuple[bytes, int]) -> None: ...
|
||||
@@ -180,24 +180,24 @@ class IncrementalDecoder:
|
||||
# These are not documented but used in encodings/*.py implementations.
|
||||
class BufferedIncrementalEncoder(IncrementalEncoder):
|
||||
buffer: str
|
||||
def __init__(self, errors: str = ...) -> None: ...
|
||||
def __init__(self, errors: str = "strict") -> None: ...
|
||||
@abstractmethod
|
||||
def _buffer_encode(self, input: str, errors: str, final: bool) -> bytes: ...
|
||||
def encode(self, input: str, final: bool = ...) -> bytes: ...
|
||||
def encode(self, input: str, final: bool = False) -> bytes: ...
|
||||
|
||||
class BufferedIncrementalDecoder(IncrementalDecoder):
|
||||
buffer: bytes
|
||||
def __init__(self, errors: str = ...) -> None: ...
|
||||
def __init__(self, errors: str = "strict") -> None: ...
|
||||
@abstractmethod
|
||||
def _buffer_decode(self, input: ReadableBuffer, errors: str, final: bool) -> tuple[str, int]: ...
|
||||
def decode(self, input: ReadableBuffer, final: bool = ...) -> str: ...
|
||||
def decode(self, input: ReadableBuffer, final: bool = False) -> str: ...
|
||||
|
||||
# TODO: it is not possible to specify the requirement that all other
|
||||
# attributes and methods are passed-through from the stream.
|
||||
class StreamWriter(Codec):
|
||||
stream: _WritableStream
|
||||
errors: str
|
||||
def __init__(self, stream: _WritableStream, errors: str = ...) -> None: ...
|
||||
def __init__(self, stream: _WritableStream, errors: str = "strict") -> None: ...
|
||||
def write(self, object: str) -> None: ...
|
||||
def writelines(self, list: Iterable[str]) -> None: ...
|
||||
def reset(self) -> None: ...
|
||||
@@ -208,10 +208,10 @@ class StreamWriter(Codec):
|
||||
class StreamReader(Codec):
|
||||
stream: _ReadableStream
|
||||
errors: str
|
||||
def __init__(self, stream: _ReadableStream, errors: str = ...) -> None: ...
|
||||
def read(self, size: int = ..., chars: int = ..., firstline: bool = ...) -> str: ...
|
||||
def readline(self, size: int | None = ..., keepends: bool = ...) -> str: ...
|
||||
def readlines(self, sizehint: int | None = ..., keepends: bool = ...) -> list[str]: ...
|
||||
def __init__(self, stream: _ReadableStream, errors: str = "strict") -> None: ...
|
||||
def read(self, size: int = -1, chars: int = -1, firstline: bool = False) -> str: ...
|
||||
def readline(self, size: int | None = None, keepends: bool = True) -> str: ...
|
||||
def readlines(self, sizehint: int | None = None, keepends: bool = True) -> list[str]: ...
|
||||
def reset(self) -> None: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ...
|
||||
@@ -223,16 +223,16 @@ class StreamReader(Codec):
|
||||
# and delegates attributes to the underlying binary stream with __getattr__.
|
||||
class StreamReaderWriter(TextIO):
|
||||
stream: _Stream
|
||||
def __init__(self, stream: _Stream, Reader: _StreamReader, Writer: _StreamWriter, errors: str = ...) -> None: ...
|
||||
def read(self, size: int = ...) -> str: ...
|
||||
def readline(self, size: int | None = ...) -> str: ...
|
||||
def readlines(self, sizehint: int | None = ...) -> list[str]: ...
|
||||
def __init__(self, stream: _Stream, Reader: _StreamReader, Writer: _StreamWriter, errors: str = "strict") -> None: ...
|
||||
def read(self, size: int = -1) -> str: ...
|
||||
def readline(self, size: int | None = None) -> str: ...
|
||||
def readlines(self, sizehint: int | None = None) -> list[str]: ...
|
||||
def __next__(self) -> str: ...
|
||||
def __iter__(self: Self) -> Self: ...
|
||||
def write(self, data: str) -> None: ... # type: ignore[override]
|
||||
def writelines(self, list: Iterable[str]) -> None: ...
|
||||
def reset(self) -> None: ...
|
||||
def seek(self, offset: int, whence: int = ...) -> None: ... # type: ignore[override]
|
||||
def seek(self, offset: int, whence: int = 0) -> None: ... # type: ignore[override]
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ...
|
||||
def __getattr__(self, name: str) -> Any: ...
|
||||
@@ -250,11 +250,17 @@ class StreamReaderWriter(TextIO):
|
||||
|
||||
class StreamRecoder(BinaryIO):
|
||||
def __init__(
|
||||
self, stream: _Stream, encode: _Encoder, decode: _Decoder, Reader: _StreamReader, Writer: _StreamWriter, errors: str = ...
|
||||
self,
|
||||
stream: _Stream,
|
||||
encode: _Encoder,
|
||||
decode: _Decoder,
|
||||
Reader: _StreamReader,
|
||||
Writer: _StreamWriter,
|
||||
errors: str = "strict",
|
||||
) -> None: ...
|
||||
def read(self, size: int = ...) -> bytes: ...
|
||||
def readline(self, size: int | None = ...) -> bytes: ...
|
||||
def readlines(self, sizehint: int | None = ...) -> list[bytes]: ...
|
||||
def read(self, size: int = -1) -> bytes: ...
|
||||
def readline(self, size: int | None = None) -> bytes: ...
|
||||
def readlines(self, sizehint: int | None = None) -> list[bytes]: ...
|
||||
def __next__(self) -> bytes: ...
|
||||
def __iter__(self: Self) -> Self: ...
|
||||
def write(self, data: bytes) -> None: ... # type: ignore[override]
|
||||
@@ -263,7 +269,7 @@ class StreamRecoder(BinaryIO):
|
||||
def __getattr__(self, name: str) -> Any: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ...
|
||||
def seek(self, offset: int, whence: int = ...) -> None: ... # type: ignore[override]
|
||||
def seek(self, offset: int, whence: int = 0) -> None: ... # type: ignore[override]
|
||||
# These methods don't actually exist directly, but they are needed to satisfy the BinaryIO
|
||||
# interface. At runtime, they are delegated through __getattr__.
|
||||
def close(self) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user