|
1 | 1 | import re |
2 | | -from collections.abc import Callable, Iterable, MutableMapping |
3 | | -from re import Match, Pattern |
4 | | -from typing import Any, ClassVar, Generic, TypeVar |
| 2 | +from collections.abc import Generator as Generator |
| 3 | +from typing import ( |
| 4 | + Any, |
| 5 | + Callable, |
| 6 | + ClassVar, |
| 7 | + Dict, |
| 8 | + Generic, |
| 9 | + Iterable, |
| 10 | + List, |
| 11 | + Match, |
| 12 | + MutableMapping, |
| 13 | + Optional, |
| 14 | + Pattern, |
| 15 | + Type, |
| 16 | + TypeVar, |
| 17 | + Union, |
| 18 | +) |
5 | 19 |
|
6 | 20 | from typing_extensions import Self |
7 | 21 |
|
8 | 22 | class BlockState: |
9 | 23 | src: str |
10 | | - tokens: list[dict[str, Any]] |
| 24 | + tokens: List[Dict[str, Any]] |
11 | 25 | cursor: int |
12 | 26 | cursor_max: int |
13 | 27 | list_tight: bool |
14 | 28 | parent: Any |
15 | 29 | env: MutableMapping[str, Any] |
16 | | - def __init__(self, parent: Any | None = None) -> None: ... |
| 30 | + def __init__(self, parent: Optional[Any] = None) -> None: ... |
17 | 31 | def child_state(self, src: str) -> BlockState: ... |
18 | 32 | def process(self, src: str) -> None: ... |
19 | 33 | def find_line_end(self) -> int: ... |
20 | 34 | def get_text(self, end_pos: int) -> str: ... |
21 | 35 | def last_token(self) -> Any: ... |
22 | | - def prepend_token(self, token: dict[str, Any]) -> None: ... |
23 | | - def append_token(self, token: dict[str, Any]) -> None: ... |
| 36 | + def prepend_token(self, token: Dict[str, Any]) -> None: ... |
| 37 | + def append_token(self, token: Dict[str, Any]) -> None: ... |
24 | 38 | def add_paragraph(self, text: str) -> None: ... |
25 | | - def append_paragraph(self) -> int | None: ... |
| 39 | + def append_paragraph(self) -> Optional[int]: ... |
26 | 40 | def depth(self) -> int: ... |
27 | 41 |
|
28 | 42 | class InlineState: |
29 | 43 | env: MutableMapping[str, Any] |
30 | 44 | src: str |
31 | | - tokens: list[dict[str, Any]] |
| 45 | + tokens: List[Dict[str, Any]] |
32 | 46 | in_image: bool |
33 | 47 | in_link: bool |
34 | 48 | in_emphasis: bool |
35 | 49 | in_strong: bool |
36 | 50 | def __init__(self, env: MutableMapping[str, Any]) -> None: ... |
37 | | - def prepend_token(self, token: dict[str, Any]) -> None: ... |
38 | | - def append_token(self, token: dict[str, Any]) -> None: ... |
| 51 | + def prepend_token(self, token: Dict[str, Any]) -> None: ... |
| 52 | + def append_token(self, token: Dict[str, Any]) -> None: ... |
39 | 53 | def copy(self) -> InlineState: ... |
40 | 54 |
|
41 | 55 | ST = TypeVar("ST", InlineState, BlockState) |
42 | 56 |
|
43 | 57 | class Parser(Generic[ST]): |
44 | 58 | sc_flag: re._FlagsType |
45 | | - state_cls: type[ST] |
46 | | - SPECIFICATION: ClassVar[dict[str, str]] |
| 59 | + state_cls: Type[ST] |
| 60 | + SPECIFICATION: ClassVar[Dict[str, str]] |
47 | 61 | DEFAULT_RULES: ClassVar[Iterable[str]] |
48 | | - specification: dict[str, str] |
| 62 | + specification: Dict[str, str] |
49 | 63 | rules: Iterable[str] |
50 | 64 | def __init__(self) -> None: ... |
51 | | - def compile_sc(self, rules: list[str] | None = None) -> Pattern[str]: ... |
| 65 | + def compile_sc(self, rules: Optional[List[str]] = None) -> Pattern[str]: ... |
52 | 66 | def register( |
53 | 67 | self, |
54 | 68 | name: str, |
55 | | - pattern: str | None, |
56 | | - func: Callable[[Self, Match[str], ST], int | None], |
57 | | - before: str | None = None, |
| 69 | + pattern: Union[str, None], |
| 70 | + func: Callable[[Self, Match[str], ST], Optional[int]], |
| 71 | + before: Optional[str] = None, |
58 | 72 | ) -> None: ... |
59 | 73 | def register_rule(self, name: str, pattern: str, func: Any) -> None: ... |
60 | 74 | @staticmethod |
61 | | - def insert_rule(rules: list[str], name: str, before: str | None = None) -> None: ... |
62 | | - def parse_method(self, m: Match[str], state: ST) -> int | None: ... |
| 75 | + def insert_rule(rules: List[str], name: str, before: Optional[str] = None) -> None: ... |
| 76 | + def parse_method(self, m: Match[str], state: ST) -> Optional[int]: ... |
63 | 77 |
|
64 | 78 | class BaseRenderer: |
65 | 79 | NAME: ClassVar[str] |
66 | 80 | def __init__(self) -> None: ... |
67 | 81 | def register(self, name: str, method: Callable[..., str]) -> None: ... |
68 | | - def render_token(self, token: dict[str, Any], state: BlockState) -> str: ... |
69 | | - def iter_tokens(self, tokens: Iterable[dict[str, Any]], state: BlockState) -> Iterable[str]: ... |
70 | | - def render_tokens(self, tokens: Iterable[dict[str, Any]], state: BlockState) -> str: ... |
71 | | - def __call__(self, tokens: Iterable[dict[str, Any]], state: BlockState) -> str: ... |
| 82 | + def render_token(self, token: Dict[str, Any], state: BlockState) -> str: ... |
| 83 | + def iter_tokens(self, tokens: Iterable[Dict[str, Any]], state: BlockState) -> Iterable[str]: ... |
| 84 | + def render_tokens(self, tokens: Iterable[Dict[str, Any]], state: BlockState) -> str: ... |
| 85 | + def __call__(self, tokens: Iterable[Dict[str, Any]], state: BlockState) -> str: ... |
0 commit comments