Use TypeAlias where possible for type aliases (#7630)

This commit is contained in:
Alex Waygood
2022-04-16 02:01:00 +01:00
committed by GitHub
parent c0e6dd3f3f
commit 740193a8fc
218 changed files with 760 additions and 625 deletions

View File

@@ -3,7 +3,7 @@ import sys
from _compression import BaseStream
from _typeshed import ReadableBuffer, Self, StrOrBytesPath, WriteableBuffer
from typing import IO, Any, Iterable, Protocol, TextIO, overload
from typing_extensions import Literal, SupportsIndex, final
from typing_extensions import Literal, SupportsIndex, TypeAlias, final
__all__ = ["BZ2File", "BZ2Compressor", "BZ2Decompressor", "open", "compress", "decompress"]
@@ -21,10 +21,10 @@ class _WritableFileobj(Protocol):
def compress(data: bytes, compresslevel: int = ...) -> bytes: ...
def decompress(data: bytes) -> bytes: ...
_ReadBinaryMode = Literal["", "r", "rb"]
_WriteBinaryMode = Literal["w", "wb", "x", "xb", "a", "ab"]
_ReadTextMode = Literal["rt"]
_WriteTextMode = Literal["wt", "xt", "at"]
_ReadBinaryMode: TypeAlias = Literal["", "r", "rb"]
_WriteBinaryMode: TypeAlias = Literal["w", "wb", "x", "xb", "a", "ab"]
_ReadTextMode: TypeAlias = Literal["rt"]
_WriteTextMode: TypeAlias = Literal["wt", "xt", "at"]
@overload
def open(