2 from sre_constants import _NamedIntConstant as _NIC, error as _Error
3 from typing import Any, Iterable, List, Match, Optional, Pattern as _Pattern, Tuple, Union, overload
8 OCTDIGITS: frozenset[str]
9 HEXDIGITS: frozenset[str]
10 ASCIILETTERS: frozenset[str]
11 WHITESPACE: frozenset[str]
12 ESCAPES: dict[str, tuple[_NIC, int]]
13 CATEGORIES: dict[str, tuple[_NIC, _NIC] | tuple[_NIC, list[tuple[_NIC, _NIC]]]]
17 class Verbose(Exception): ...
21 groupdict: dict[str, int]
22 groupwidths: list[int | None]
23 lookbehindgroups: int | None
24 def __init__(self) -> None: ...
26 def groups(self) -> int: ...
27 def opengroup(self, name: str = ...) -> int: ...
28 def closegroup(self, gid: int, p: SubPattern) -> None: ...
29 def checkgroup(self, gid: int) -> bool: ...
30 def checklookbehindgroup(self, gid: int, source: Tokenizer) -> None: ...
32 if sys.version_info >= (3, 8):
37 _OpSubpatternType = Tuple[Optional[int], int, int, SubPattern]
38 _OpGroupRefExistsType = Tuple[int, SubPattern, SubPattern]
39 _OpInType = List[Tuple[_NIC, int]]
40 _OpBranchType = Tuple[None, List[SubPattern]]
41 _AvType = Union[_OpInType, _OpBranchType, Iterable[SubPattern], _OpGroupRefExistsType, _OpSubpatternType]
42 _CodeType = Tuple[_NIC, _AvType]
48 if sys.version_info >= (3, 8):
50 def __init__(self, state: State, data: list[_CodeType] | None = ...) -> None: ...
53 def __init__(self, pattern: Pattern, data: list[_CodeType] | None = ...) -> None: ...
54 def dump(self, level: int = ...) -> None: ...
55 def __len__(self) -> int: ...
56 def __delitem__(self, index: int | slice) -> None: ...
57 def __getitem__(self, index: int | slice) -> SubPattern | _CodeType: ...
58 def __setitem__(self, index: int | slice, code: _CodeType) -> None: ...
59 def insert(self, index: int, code: _CodeType) -> None: ...
60 def append(self, code: _CodeType) -> None: ...
61 def getwidth(self) -> int: ...
69 def __init__(self, string: Any) -> None: ...
70 def match(self, char: str) -> bool: ...
71 def get(self) -> str | None: ...
72 def getwhile(self, n: int, charset: Iterable[str]) -> str: ...
73 if sys.version_info >= (3, 8):
74 def getuntil(self, terminator: str, name: str) -> str: ...
76 def getuntil(self, terminator: str) -> str: ...
78 def pos(self) -> int: ...
79 def tell(self) -> int: ...
80 def seek(self, index: int) -> None: ...
81 def error(self, msg: str, offset: int = ...) -> _Error: ...
83 def fix_flags(src: str | bytes, flags: int) -> int: ...
85 _TemplateType = Tuple[List[Tuple[int, int]], List[Optional[str]]]
86 _TemplateByteType = Tuple[List[Tuple[int, int]], List[Optional[bytes]]]
87 if sys.version_info >= (3, 8):
88 def parse(str: str, flags: int = ..., state: State | None = ...) -> SubPattern: ...
90 def parse_template(source: str, state: _Pattern[Any]) -> _TemplateType: ...
92 def parse_template(source: bytes, state: _Pattern[Any]) -> _TemplateByteType: ...
95 def parse(str: str, flags: int = ..., pattern: Pattern | None = ...) -> SubPattern: ...
97 def parse_template(source: str, pattern: _Pattern[Any]) -> _TemplateType: ...
99 def parse_template(source: bytes, pattern: _Pattern[Any]) -> _TemplateByteType: ...
101 def expand_template(template: _TemplateType, match: Match[Any]) -> str: ...