Skip to content

Commit 3369007

Browse files
committed
Set no_implicit_optional=True mypy conf
1 parent f39a610 commit 3369007

File tree

6 files changed

+24
-11
lines changed

6 files changed

+24
-11
lines changed

.mypy.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
[mypy]
22
warn_unused_ignores = True
33
warn_redundant_casts = True
4+
no_implicit_optional = True

markdown_it/common/normalize_url.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import html
22
import re
3-
from typing import Callable
3+
from typing import Callable, Optional
44
from urllib.parse import urlparse, urlunparse, quote, unquote # noqa: F401
55

66
from .utils import ESCAPABLE
@@ -166,7 +166,7 @@ def normalizeLinkText(link):
166166
GOOD_DATA_RE = re.compile(r"^data:image\/(gif|png|jpeg|webp);")
167167

168168

169-
def validateLink(url: str, validator: Callable = None):
169+
def validateLink(url: str, validator: Optional[Callable] = None):
170170
"""Validate URL link is allowed in output.
171171
172172
This validator can prohibit more than really needed to prevent XSS.

markdown_it/extensions/container/index.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Process block-level custom containers."""
22
from math import floor
3-
from typing import Callable
3+
from typing import Callable, Optional
44

55
from markdown_it import MarkdownIt
66
from markdown_it.common.utils import charCodeAt
@@ -11,7 +11,7 @@ def container_plugin(
1111
md: MarkdownIt,
1212
name: str,
1313
marker: str = ":",
14-
validate: Callable[[str, str], bool] = None,
14+
validate: Optional[Callable[[str, str], bool]] = None,
1515
render=None,
1616
):
1717
"""Plugin ported from

markdown_it/parser_block.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Block-level tokenizer."""
22
import logging
3-
from typing import List
3+
from typing import List, Optional
44

55
from .ruler import Ruler
66
from .token import Token
@@ -92,7 +92,14 @@ def tokenize(
9292
line += 1
9393
state.line = line
9494

95-
def parse(self, src: str, md, env, outTokens: List[Token], ords: List[int] = None):
95+
def parse(
96+
self,
97+
src: str,
98+
md,
99+
env,
100+
outTokens: List[Token],
101+
ords: Optional[List[int]] = None,
102+
):
96103
"""Process input string and push block tokens into `outTokens`."""
97104
if not src:
98105
return

markdown_it/rules_block/state_block.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import List
1+
from typing import List, Optional
22

33
from ..token import Token
44
from ..ruler import StateBase
@@ -7,7 +7,12 @@
77

88
class StateBlock(StateBase):
99
def __init__(
10-
self, src: str, md, env, tokens: List[Token], srcCharCode: List[int] = None
10+
self,
11+
src: str,
12+
md,
13+
env,
14+
tokens: List[Token],
15+
srcCharCode: Optional[List[int]] = None,
1116
):
1217

1318
self.src = src

markdown_it/rules_core/smartquotes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Convert straight quotation marks to typographic ones
22
"""
33
import re
4-
from typing import List
4+
from typing import Any, Dict, List
55

66
from .state_core import StateCore
77
from ..common.utils import charCodeAt
@@ -22,7 +22,7 @@ def replaceAt(string: str, index: int, ch: str):
2222

2323

2424
def process_inlines(tokens: List[Token], state: StateCore):
25-
stack = []
25+
stack: List[Dict[str, Any]] = []
2626

2727
for i in range(len(tokens)):
2828
token = tokens[i]
@@ -202,5 +202,5 @@ def smartquotes(state: StateCore):
202202

203203
if token.type != "inline" or not QUOTE_RE.search(token.content):
204204
continue
205-
205+
assert token.children is not None
206206
process_inlines(token.children, state)

0 commit comments

Comments
 (0)