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