Use PEP 585 syntax wherever possible (#6717)

This commit is contained in:
Alex Waygood
2021-12-28 10:31:43 +00:00
committed by GitHub
parent e6cb341d94
commit 8d5d2520ac
237 changed files with 966 additions and 1069 deletions

View File

@@ -1,7 +1,7 @@
import sys
from sre_constants import *
from sre_constants import _NamedIntConstant as _NIC, error as _Error
from typing import Any, Iterable, List, Match, Optional, Pattern as _Pattern, Tuple, Union, overload
from typing import Any, Iterable, Match, Optional, Pattern as _Pattern, Union, overload
SPECIAL_CHARS: str
REPEAT_CHARS: str
@@ -37,12 +37,12 @@ if sys.version_info >= (3, 8):
else:
Pattern = _State
_OpSubpatternType = Tuple[Optional[int], int, int, SubPattern]
_OpGroupRefExistsType = Tuple[int, SubPattern, SubPattern]
_OpInType = List[Tuple[_NIC, int]]
_OpBranchType = Tuple[None, List[SubPattern]]
_OpSubpatternType = tuple[Optional[int], int, int, SubPattern]
_OpGroupRefExistsType = tuple[int, SubPattern, SubPattern]
_OpInType = list[tuple[_NIC, int]]
_OpBranchType = tuple[None, list[SubPattern]]
_AvType = Union[_OpInType, _OpBranchType, Iterable[SubPattern], _OpGroupRefExistsType, _OpSubpatternType]
_CodeType = Tuple[_NIC, _AvType]
_CodeType = tuple[_NIC, _AvType]
class SubPattern:
data: list[_CodeType]
@@ -85,8 +85,8 @@ class Tokenizer:
def fix_flags(src: str | bytes, flags: int) -> int: ...
_TemplateType = Tuple[List[Tuple[int, int]], List[Optional[str]]]
_TemplateByteType = Tuple[List[Tuple[int, int]], List[Optional[bytes]]]
_TemplateType = tuple[list[tuple[int, int]], list[Optional[str]]]
_TemplateByteType = tuple[list[tuple[int, int]], list[Optional[bytes]]]
if sys.version_info >= (3, 8):
def parse(str: str, flags: int = ..., state: State | None = ...) -> SubPattern: ...
@overload