Skip to content

Commit e6c1b18

Browse files
committed
chore: resolve mypy issues
1 parent dcf8902 commit e6c1b18

2 files changed

Lines changed: 16 additions & 12 deletions

File tree

‎src/mistune/inline_parser.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,9 @@ def _is_link_like(src: str, pos: int, state: InlineState) -> bool:
811811
if label is None:
812812
return False
813813

814+
assert label is not None
815+
assert end_pos is not None
816+
814817
if end_pos >= len(src):
815818
ref_links = state.env.get("ref_links")
816819
return bool(ref_links and unikey(label) in ref_links)

‎src/mistune/plugins/table.py‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,36 +102,37 @@ def parse_nptable(block: "BlockParser", m: Match[str], state: "BlockState") -> O
102102
return pos
103103

104104

105-
def _process_thead(header: str, align: str) -> Union[Tuple[None, None], Tuple[Dict[str, Any], List[str]]]:
105+
def _process_thead(header: str, align: str) -> Union[Tuple[None, None], Tuple[Dict[str, Any], List[Optional[str]]]]:
106106
headers = _split_table_cells(header)
107-
aligns = _split_table_cells(align)
108-
if len(headers) != len(aligns):
107+
raw_aligns = _split_table_cells(align)
108+
if len(headers) != len(raw_aligns):
109109
return None, None
110110

111-
for i, v in enumerate(aligns):
111+
aligns: List[Optional[str]] = []
112+
for v in raw_aligns:
112113
if ALIGN_CENTER.match(v):
113-
aligns[i] = "center"
114+
aligns.append("center")
114115
elif ALIGN_LEFT.match(v):
115-
aligns[i] = "left"
116+
aligns.append("left")
116117
elif ALIGN_RIGHT.match(v):
117-
aligns[i] = "right"
118+
aligns.append("right")
118119
else:
119-
aligns[i] = None
120+
aligns.append(None)
120121

121-
children = [
122+
children: List[Dict[str, Any]] = [
122123
{"type": "table_cell", "text": text.strip(), "attrs": {"align": aligns[i], "head": True}}
123124
for i, text in enumerate(headers)
124125
]
125-
thead = {"type": "table_head", "children": children}
126+
thead: Dict[str, Any] = {"type": "table_head", "children": children}
126127
return thead, aligns
127128

128129

129-
def _process_row(text: str, aligns: List[str]) -> Optional[Dict[str, Any]]:
130+
def _process_row(text: str, aligns: List[Optional[str]]) -> Optional[Dict[str, Any]]:
130131
cells = _split_table_cells(text)
131132
if len(cells) != len(aligns):
132133
return None
133134

134-
children = [
135+
children: List[Dict[str, Any]] = [
135136
{"type": "table_cell", "text": text.strip(), "attrs": {"align": aligns[i], "head": False}}
136137
for i, text in enumerate(cells)
137138
]

0 commit comments

Comments
 (0)