mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-26 03:27:14 +08:00
Use TypeAlias where possible for type aliases (#7630)
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
from _typeshed import Self, StrPath
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_Label = tuple[int, str | None]
|
||||
_DFA = list[list[tuple[int, int]]]
|
||||
_DFAS = tuple[_DFA, dict[int, int]]
|
||||
_Label: TypeAlias = tuple[int, str | None]
|
||||
_DFA: TypeAlias = list[list[tuple[int, int]]]
|
||||
_DFAS: TypeAlias = tuple[_DFA, dict[int, int]]
|
||||
|
||||
class Grammar:
|
||||
symbol2number: dict[str, int]
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
from lib2to3.pgen2.grammar import _DFAS, Grammar
|
||||
from lib2to3.pytree import _NL, _Convert, _RawNode
|
||||
from typing import Any, Sequence
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
_Context = Sequence[Any]
|
||||
_Context: TypeAlias = Sequence[Any]
|
||||
|
||||
class ParseError(Exception):
|
||||
msg: str
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import sys
|
||||
from lib2to3.pgen2.token import *
|
||||
from typing import Callable, Iterable, Iterator
|
||||
from typing_extensions import TypeAlias
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
__all__ = [
|
||||
@@ -146,9 +147,9 @@ else:
|
||||
"untokenize",
|
||||
]
|
||||
|
||||
_Coord = tuple[int, int]
|
||||
_TokenEater = Callable[[int, str, _Coord, _Coord, str], None]
|
||||
_TokenInfo = tuple[int, str, _Coord, _Coord, str]
|
||||
_Coord: TypeAlias = tuple[int, int]
|
||||
_TokenEater: TypeAlias = Callable[[int, str, _Coord, _Coord, str], None]
|
||||
_TokenInfo: TypeAlias = tuple[int, str, _Coord, _Coord, str]
|
||||
|
||||
class TokenError(Exception): ...
|
||||
class StopTokenizing(Exception): ...
|
||||
|
||||
Reference in New Issue
Block a user