Skip to content

Commit 17c50f6

Browse files
committed
chore: fix mypy issues
1 parent 63abe4b commit 17c50f6

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/mistune/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
Type,
1818
TypeVar,
1919
Union,
20+
cast,
2021
)
2122

2223
if sys.version_info >= (3, 11):
@@ -246,7 +247,7 @@ def render_wiki(renderer, key, title):
246247

247248
def _get_method(self, name: str) -> Callable[..., str]:
248249
try:
249-
return object.__getattribute__(self, name)
250+
return cast(Callable[..., str], object.__getattribute__(self, name))
250251
except AttributeError:
251252
method = self.__methods.get(name)
252253
if not method:

src/mistune/inline_parser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
Optional,
1010
Set,
1111
Tuple,
12+
cast,
1213
)
1314

1415
from .core import InlineState, Parser
@@ -717,7 +718,7 @@ def _has_emphasis_enabled(parts: List[Dict[str, Any]], opener: _Delimiter, close
717718

718719
def _text_raw(token: Dict[str, Any]) -> str:
719720
if token["type"] == "text":
720-
return token["raw"]
721+
return cast(str, token["raw"])
721722
return ""
722723

723724

src/mistune/toc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import re
2-
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Tuple
2+
from typing import TYPE_CHECKING, Any, Callable, Dict, Iterable, List, Optional, Set, Tuple
33

44
from .core import BlockState
55
from .util import striptags, escape
@@ -68,11 +68,11 @@ def toc_hook(md: "Markdown", state: "BlockState") -> None:
6868
md.before_render_hooks.append(toc_hook)
6969

7070

71-
def _find_html_ids(src: str) -> set:
71+
def _find_html_ids(src: str) -> Set[str]:
7272
return {m.group(1) or m.group(2) for m in _HTML_ID_RE.finditer(src)}
7373

7474

75-
def _unique_id(value: str, used_ids: set) -> str:
75+
def _unique_id(value: str, used_ids: Set[str]) -> str:
7676
if value not in used_ids:
7777
return value
7878

0 commit comments

Comments
 (0)