mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 21:14:48 +08:00
Big diff: Use new "|" union syntax (#5872)
This commit is contained in:
@@ -4,7 +4,7 @@ import sys
|
||||
from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer
|
||||
from os import _Opener
|
||||
from types import TracebackType
|
||||
from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, List, Optional, TextIO, Tuple, Type, Union
|
||||
from typing import IO, Any, BinaryIO, Callable, Iterable, Iterator, List, TextIO, Tuple, Type
|
||||
|
||||
DEFAULT_BUFFER_SIZE: int
|
||||
|
||||
@@ -26,8 +26,8 @@ class IOBase:
|
||||
def __next__(self) -> bytes: ...
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
def __exit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
|
||||
) -> Optional[bool]: ...
|
||||
self, exc_type: Type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
|
||||
) -> bool | None: ...
|
||||
def close(self) -> None: ...
|
||||
def fileno(self) -> int: ...
|
||||
def flush(self) -> None: ...
|
||||
@@ -38,21 +38,21 @@ class IOBase:
|
||||
def seek(self, __offset: int, __whence: int = ...) -> int: ...
|
||||
def seekable(self) -> bool: ...
|
||||
def tell(self) -> int: ...
|
||||
def truncate(self, __size: Optional[int] = ...) -> int: ...
|
||||
def truncate(self, __size: int | None = ...) -> int: ...
|
||||
def writable(self) -> bool: ...
|
||||
write: Callable[..., Any]
|
||||
def writelines(self, __lines: Iterable[ReadableBuffer]) -> None: ...
|
||||
def readline(self, __size: Optional[int] = ...) -> bytes: ...
|
||||
def readline(self, __size: int | None = ...) -> bytes: ...
|
||||
def __del__(self) -> None: ...
|
||||
@property
|
||||
def closed(self) -> bool: ...
|
||||
def _checkClosed(self, msg: Optional[str] = ...) -> None: ... # undocumented
|
||||
def _checkClosed(self, msg: str | None = ...) -> None: ... # undocumented
|
||||
|
||||
class RawIOBase(IOBase):
|
||||
def readall(self) -> bytes: ...
|
||||
def readinto(self, __buffer: WriteableBuffer) -> Optional[int]: ...
|
||||
def write(self, __b: ReadableBuffer) -> Optional[int]: ...
|
||||
def read(self, __size: int = ...) -> Optional[bytes]: ...
|
||||
def readinto(self, __buffer: WriteableBuffer) -> int | None: ...
|
||||
def write(self, __b: ReadableBuffer) -> int | None: ...
|
||||
def read(self, __size: int = ...) -> bytes | None: ...
|
||||
|
||||
class BufferedIOBase(IOBase):
|
||||
raw: RawIOBase # This is not part of the BufferedIOBase API and may not exist on some implementations.
|
||||
@@ -60,7 +60,7 @@ class BufferedIOBase(IOBase):
|
||||
def readinto(self, __buffer: WriteableBuffer) -> int: ...
|
||||
def write(self, __buffer: ReadableBuffer) -> int: ...
|
||||
def readinto1(self, __buffer: WriteableBuffer) -> int: ...
|
||||
def read(self, __size: Optional[int] = ...) -> bytes: ...
|
||||
def read(self, __size: int | None = ...) -> bytes: ...
|
||||
def read1(self, __size: int = ...) -> bytes: ...
|
||||
|
||||
class FileIO(RawIOBase, BinaryIO):
|
||||
@@ -85,9 +85,9 @@ class BytesIO(BufferedIOBase, BinaryIO):
|
||||
def getvalue(self) -> bytes: ...
|
||||
def getbuffer(self) -> memoryview: ...
|
||||
if sys.version_info >= (3, 7):
|
||||
def read1(self, __size: Optional[int] = ...) -> bytes: ...
|
||||
def read1(self, __size: int | None = ...) -> bytes: ...
|
||||
else:
|
||||
def read1(self, __size: Optional[int]) -> bytes: ... # type: ignore
|
||||
def read1(self, __size: int | None) -> bytes: ... # type: ignore
|
||||
|
||||
class BufferedReader(BufferedIOBase, BinaryIO):
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
@@ -118,8 +118,8 @@ class BufferedRWPair(BufferedIOBase):
|
||||
|
||||
class TextIOBase(IOBase):
|
||||
encoding: str
|
||||
errors: Optional[str]
|
||||
newlines: Union[str, Tuple[str, ...], None]
|
||||
errors: str | None
|
||||
newlines: str | Tuple[str, ...] | None
|
||||
def __iter__(self) -> Iterator[str]: ... # type: ignore
|
||||
def __next__(self) -> str: ... # type: ignore
|
||||
def detach(self) -> BinaryIO: ...
|
||||
@@ -127,16 +127,16 @@ class TextIOBase(IOBase):
|
||||
def writelines(self, __lines: Iterable[str]) -> None: ... # type: ignore
|
||||
def readline(self, __size: int = ...) -> str: ... # type: ignore
|
||||
def readlines(self, __hint: int = ...) -> List[str]: ... # type: ignore
|
||||
def read(self, __size: Optional[int] = ...) -> str: ...
|
||||
def read(self, __size: int | None = ...) -> str: ...
|
||||
def tell(self) -> int: ...
|
||||
|
||||
class TextIOWrapper(TextIOBase, TextIO):
|
||||
def __init__(
|
||||
self,
|
||||
buffer: IO[bytes],
|
||||
encoding: Optional[str] = ...,
|
||||
errors: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
encoding: str | None = ...,
|
||||
errors: str | None = ...,
|
||||
newline: str | None = ...,
|
||||
line_buffering: bool = ...,
|
||||
write_through: bool = ...,
|
||||
) -> None: ...
|
||||
@@ -152,11 +152,11 @@ class TextIOWrapper(TextIOBase, TextIO):
|
||||
def reconfigure(
|
||||
self,
|
||||
*,
|
||||
encoding: Optional[str] = ...,
|
||||
errors: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
line_buffering: Optional[bool] = ...,
|
||||
write_through: Optional[bool] = ...,
|
||||
encoding: str | None = ...,
|
||||
errors: str | None = ...,
|
||||
newline: str | None = ...,
|
||||
line_buffering: bool | None = ...,
|
||||
write_through: bool | None = ...,
|
||||
) -> None: ...
|
||||
# These are inherited from TextIOBase, but must exist in the stub to satisfy mypy.
|
||||
def __enter__(self: Self) -> Self: ...
|
||||
@@ -168,7 +168,7 @@ class TextIOWrapper(TextIOBase, TextIO):
|
||||
def seek(self, __cookie: int, __whence: int = ...) -> int: ...
|
||||
|
||||
class StringIO(TextIOWrapper):
|
||||
def __init__(self, initial_value: Optional[str] = ..., newline: Optional[str] = ...) -> None: ...
|
||||
def __init__(self, initial_value: str | None = ..., newline: str | None = ...) -> None: ...
|
||||
# StringIO does not contain a "name" field. This workaround is necessary
|
||||
# to allow StringIO sub-classes to add this field, as it is defined
|
||||
# as a read-only property on IO[].
|
||||
@@ -176,7 +176,7 @@ class StringIO(TextIOWrapper):
|
||||
def getvalue(self) -> str: ...
|
||||
|
||||
class IncrementalNewlineDecoder(codecs.IncrementalDecoder):
|
||||
def __init__(self, decoder: Optional[codecs.IncrementalDecoder], translate: bool, errors: str = ...) -> None: ...
|
||||
def decode(self, input: Union[bytes, str], final: bool = ...) -> str: ...
|
||||
def __init__(self, decoder: codecs.IncrementalDecoder | None, translate: bool, errors: str = ...) -> None: ...
|
||||
def decode(self, input: bytes | str, final: bool = ...) -> str: ...
|
||||
@property
|
||||
def newlines(self) -> Optional[Union[str, Tuple[str, ...]]]: ...
|
||||
def newlines(self) -> str | Tuple[str, ...] | None: ...
|
||||
|
||||
Reference in New Issue
Block a user