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,6 +3,7 @@ from _typeshed import StrOrBytesPath
from builtins import open as _builtin_open
from token import *
from typing import Any, Callable, Generator, Iterable, NamedTuple, Pattern, Sequence, TextIO
from typing_extensions import TypeAlias
if sys.version_info >= (3, 10):
__all__ = [
@@ -317,7 +318,7 @@ if sys.version_info < (3, 7):
cookie_re: Pattern[str]
blank_re: Pattern[bytes]
_Position = tuple[int, int]
_Position: TypeAlias = tuple[int, int]
class _TokenInfo(NamedTuple):
type: int
@@ -331,7 +332,7 @@ class TokenInfo(_TokenInfo):
def exact_type(self) -> int: ...
# Backwards compatible tokens can be sequences of a shorter length too
_Token = TokenInfo | Sequence[int | str | _Position]
_Token: TypeAlias = TokenInfo | Sequence[int | str | _Position]
class TokenError(Exception): ...
class StopTokenizing(Exception): ... # undocumented