mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
Big diff: Use new "|" union syntax (#5872)
This commit is contained in:
@@ -2,7 +2,7 @@ import _compression
|
||||
import sys
|
||||
from _compression import BaseStream
|
||||
from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer
|
||||
from typing import IO, Any, Iterable, List, Optional, Protocol, TextIO, TypeVar, Union, overload
|
||||
from typing import IO, Any, Iterable, List, Protocol, TextIO, TypeVar, overload
|
||||
from typing_extensions import Literal, SupportsIndex
|
||||
|
||||
# The following attributes and methods are optional:
|
||||
@@ -40,9 +40,9 @@ def open(
|
||||
filename: _ReadableFileobj,
|
||||
mode: _ReadTextMode,
|
||||
compresslevel: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
errors: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
encoding: str | None = ...,
|
||||
errors: str | None = ...,
|
||||
newline: str | None = ...,
|
||||
) -> TextIO: ...
|
||||
@overload
|
||||
def open(
|
||||
@@ -58,14 +58,14 @@ def open(
|
||||
filename: _WritableFileobj,
|
||||
mode: _WriteTextMode,
|
||||
compresslevel: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
errors: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
encoding: str | None = ...,
|
||||
errors: str | None = ...,
|
||||
newline: str | None = ...,
|
||||
) -> TextIO: ...
|
||||
@overload
|
||||
def open(
|
||||
filename: StrOrBytesPath,
|
||||
mode: Union[_ReadBinaryMode, _WriteBinaryMode] = ...,
|
||||
mode: _ReadBinaryMode | _WriteBinaryMode = ...,
|
||||
compresslevel: int = ...,
|
||||
encoding: None = ...,
|
||||
errors: None = ...,
|
||||
@@ -74,11 +74,11 @@ def open(
|
||||
@overload
|
||||
def open(
|
||||
filename: StrOrBytesPath,
|
||||
mode: Union[_ReadTextMode, _WriteTextMode],
|
||||
mode: _ReadTextMode | _WriteTextMode,
|
||||
compresslevel: int = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
errors: Optional[str] = ...,
|
||||
newline: Optional[str] = ...,
|
||||
encoding: str | None = ...,
|
||||
errors: str | None = ...,
|
||||
newline: str | None = ...,
|
||||
) -> TextIO: ...
|
||||
|
||||
class BZ2File(BaseStream, IO[bytes]):
|
||||
@@ -90,30 +90,26 @@ class BZ2File(BaseStream, IO[bytes]):
|
||||
def __init__(self, filename: _ReadableFileobj, mode: _ReadBinaryMode = ..., *, compresslevel: int = ...) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self, filename: StrOrBytesPath, mode: Union[_ReadBinaryMode, _WriteBinaryMode] = ..., *, compresslevel: int = ...
|
||||
self, filename: StrOrBytesPath, mode: _ReadBinaryMode | _WriteBinaryMode = ..., *, compresslevel: int = ...
|
||||
) -> None: ...
|
||||
else:
|
||||
@overload
|
||||
def __init__(
|
||||
self, filename: _WritableFileobj, mode: _WriteBinaryMode, buffering: Optional[Any] = ..., compresslevel: int = ...
|
||||
self, filename: _WritableFileobj, mode: _WriteBinaryMode, buffering: Any | None = ..., compresslevel: int = ...
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self,
|
||||
filename: _ReadableFileobj,
|
||||
mode: _ReadBinaryMode = ...,
|
||||
buffering: Optional[Any] = ...,
|
||||
compresslevel: int = ...,
|
||||
self, filename: _ReadableFileobj, mode: _ReadBinaryMode = ..., buffering: Any | None = ..., compresslevel: int = ...
|
||||
) -> None: ...
|
||||
@overload
|
||||
def __init__(
|
||||
self,
|
||||
filename: StrOrBytesPath,
|
||||
mode: Union[_ReadBinaryMode, _WriteBinaryMode] = ...,
|
||||
buffering: Optional[Any] = ...,
|
||||
mode: _ReadBinaryMode | _WriteBinaryMode = ...,
|
||||
buffering: Any | None = ...,
|
||||
compresslevel: int = ...,
|
||||
) -> None: ...
|
||||
def read(self, size: Optional[int] = ...) -> bytes: ...
|
||||
def read(self, size: int | None = ...) -> bytes: ...
|
||||
def read1(self, size: int = ...) -> bytes: ...
|
||||
def readline(self, size: SupportsIndex = ...) -> bytes: ... # type: ignore
|
||||
def readinto(self, b: WriteableBuffer) -> int: ...
|
||||
|
||||
Reference in New Issue
Block a user