Skip to content

Commit

Permalink
Use cast instead of Any
Browse files Browse the repository at this point in the history
This isn't necessary to pass mypy, but offers a little more clarity.
  • Loading branch information
bhrutledge committed Mar 12, 2022
1 parent 4ea472f commit 9a5028e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions readme_renderer/markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import re
import warnings
from typing import Any, Dict, Callable, Match, Optional
from typing import cast, Any, Dict, Callable, Match, Optional

from html import unescape

Expand All @@ -33,13 +33,13 @@
try:
import cmarkgfm
from cmarkgfm.cmark import Options as cmarkgfmOptions
variants: Dict[str, Callable[[str], Any]] = {
"GFM": lambda raw: cmarkgfm.github_flavored_markdown_to_html(
variants: Dict[str, Callable[[str], str]] = {
"GFM": lambda raw: cast(str, cmarkgfm.github_flavored_markdown_to_html(
raw, options=cmarkgfmOptions.CMARK_OPT_UNSAFE
),
"CommonMark": lambda raw: cmarkgfm.markdown_to_html(
)),
"CommonMark": lambda raw: cast(str, cmarkgfm.markdown_to_html(
raw, options=cmarkgfmOptions.CMARK_OPT_UNSAFE
),
)),
}
except ImportError:
warnings.warn(_EXTRA_WARNING)
Expand Down

0 comments on commit 9a5028e

Please sign in to comment.