Skip to content

Commit 9e57524

Browse files
authored
🔧 Update pre-commit (#64)
1 parent 4601e15 commit 9e57524

File tree

21 files changed

+33
-75
lines changed

21 files changed

+33
-75
lines changed

‎.pre-commit-config.yaml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,31 +12,30 @@ exclude: >
1212
repos:
1313

1414
- repo: https://github.com/pre-commit/pre-commit-hooks
15-
rev: v4.3.0
15+
rev: v4.4.0
1616
hooks:
1717
- id: check-json
1818
- id: check-yaml
1919
- id: end-of-file-fixer
2020
- id: trailing-whitespace
2121

2222
- repo: https://github.com/timothycrosley/isort
23-
rev: 5.10.1
23+
rev: 5.12.0
2424
hooks:
2525
- id: isort
2626

2727
- repo: https://github.com/psf/black
28-
rev: 22.8.0
28+
rev: 23.1.0
2929
hooks:
3030
- id: black
3131

32-
- repo: https://github.com/pycqa/flake8
33-
rev: 3.9.2
32+
- repo: https://github.com/charliermarsh/ruff-pre-commit
33+
rev: v0.0.247
3434
hooks:
35-
- id: flake8
36-
additional_dependencies: [flake8-bugbear==21.3.1]
35+
- id: ruff
3736

3837
- repo: https://github.com/pre-commit/mirrors-mypy
39-
rev: v0.971
38+
rev: v1.0.0
4039
hooks:
4140
- id: mypy
4241
additional_dependencies: [markdown-it-py~=2.0]

‎mdit_py_plugins/admon/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def admonition(state: StateBlock, startLine: int, endLine: int, silent: bool) ->
3838
maximum = state.eMarks[startLine]
3939

4040
# Check out the first character quickly, which should filter out most of non-containers
41-
if MARKER_CHAR != ord(state.src[start]):
41+
if ord(state.src[start]) != MARKER_CHAR:
4242
return False
4343

4444
# Check out the rest of the marker string

‎mdit_py_plugins/amsmath/__init__.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
ENVIRONMENTS = [
1212
# 3.2 single equation with an automatically gen-erated number
1313
"equation",
14-
# 3.3 variation equation, used for equations that don’t fit on a single line
14+
# 3.3 variation equation, used for equations that dont fit on a single line
1515
"multline",
1616
# 3.5 a group of consecutive equations when there is no alignment desired among them
1717
"gather",
@@ -68,10 +68,7 @@ def amsmath_plugin(md: MarkdownIt, *, renderer: Optional[Callable[[str], str]] =
6868
{"alt": ["paragraph", "reference", "blockquote", "list", "footnote_def"]},
6969
)
7070

71-
if renderer is None:
72-
_renderer = lambda content: escapeHtml(content)
73-
else:
74-
_renderer = renderer
71+
_renderer = lambda content: escapeHtml(content) if renderer is None else renderer
7572

7673
def render_amsmath_block(self, tokens, idx, options, env):
7774
content = _renderer(str(tokens[idx].content))
@@ -95,7 +92,6 @@ def match_environment(string):
9592

9693

9794
def amsmath_block(state: StateBlock, startLine: int, endLine: int, silent: bool):
98-
9995
# if it's indented more than 3 spaces, it should be a code block
10096
if state.sCount[startLine] - state.blkIndent >= 4:
10197
return False

‎mdit_py_plugins/anchors/index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def _make_anchors_func(
6767
):
6868
def _anchor_func(state: StateCore):
6969
slugs: Set[str] = set()
70-
for (idx, token) in enumerate(state.tokens):
70+
for idx, token in enumerate(state.tokens):
7171
if token.type != "heading_open":
7272
continue
7373
level = int(token.tag[1])

‎mdit_py_plugins/attrs/parse.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,12 @@ def parse(string: str) -> tuple[int, dict[str, str]]:
113113

114114

115115
def handle_start(char: str, pos: int, tokens: TokenState) -> State:
116-
117116
if char == "{":
118117
return State.SCANNING
119118
raise ParseError("Attributes must start with '{'", pos)
120119

121120

122121
def handle_scanning(char: str, pos: int, tokens: TokenState) -> State:
123-
124122
if char == " " or char == "\t" or char == "\n" or char == "\r":
125123
return State.SCANNING
126124
if char == "}":
@@ -142,15 +140,13 @@ def handle_scanning(char: str, pos: int, tokens: TokenState) -> State:
142140

143141

144142
def handle_scanning_comment(char: str, pos: int, tokens: TokenState) -> State:
145-
146143
if char == "%":
147144
return State.SCANNING
148145

149146
return State.SCANNING_COMMENT
150147

151148

152149
def handle_scanning_id(char: str, pos: int, tokens: TokenState) -> State:
153-
154150
if not REGEX_SPACE_PUNCTUATION.fullmatch(char):
155151
return State.SCANNING_ID
156152

@@ -168,7 +164,6 @@ def handle_scanning_id(char: str, pos: int, tokens: TokenState) -> State:
168164

169165

170166
def handle_scanning_class(char: str, pos: int, tokens: TokenState) -> State:
171-
172167
if not REGEX_SPACE_PUNCTUATION.fullmatch(char):
173168
return State.SCANNING_CLASS
174169

@@ -186,7 +181,6 @@ def handle_scanning_class(char: str, pos: int, tokens: TokenState) -> State:
186181

187182

188183
def handle_scanning_key(char: str, pos: int, tokens: TokenState) -> State:
189-
190184
if char == "=":
191185
tokens.append(tokens.start, pos, "key")
192186
return State.SCANNING_VALUE
@@ -198,7 +192,6 @@ def handle_scanning_key(char: str, pos: int, tokens: TokenState) -> State:
198192

199193

200194
def handle_scanning_value(char: str, pos: int, tokens: TokenState) -> State:
201-
202195
if char == '"':
203196
tokens.set_start(pos)
204197
return State.SCANNING_QUOTED_VALUE
@@ -211,7 +204,6 @@ def handle_scanning_value(char: str, pos: int, tokens: TokenState) -> State:
211204

212205

213206
def handle_scanning_bare_value(char: str, pos: int, tokens: TokenState) -> State:
214-
215207
if REGEX_KEY_CHARACTERS.fullmatch(char):
216208
return State.SCANNING_BARE_VALUE
217209

@@ -231,7 +223,6 @@ def handle_scanning_escaped(char: str, pos: int, tokens: TokenState) -> State:
231223

232224

233225
def handle_scanning_quoted_value(char: str, pos: int, tokens: TokenState) -> State:
234-
235226
if char == '"':
236227
tokens.append(tokens.start + 1, pos, "value")
237228
return State.SCANNING

‎mdit_py_plugins/colon_fence.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ def colon_fence_plugin(md: MarkdownIt):
2424

2525

2626
def _rule(state: StateBlock, startLine: int, endLine: int, silent: bool):
27-
2827
haveEndMarker = False
2928
pos = state.bMarks[startLine] + state.tShift[startLine]
3029
maximum = state.eMarks[startLine]

‎mdit_py_plugins/container/index.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ def renderDefault(self, tokens, idx, _options, env):
5252
render = render or renderDefault
5353

5454
def container_func(state: StateBlock, startLine: int, endLine: int, silent: bool):
55-
5655
auto_closed = False
5756
start = state.bMarks[startLine] + state.tShift[startLine]
5857
maximum = state.eMarks[startLine]

‎mdit_py_plugins/deflist/index.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def deflist_plugin(md: MarkdownIt):
2222
~ Definition 2b
2323
2424
"""
25-
isSpace = md.utils.isSpace # type: ignore
25+
isSpace = md.utils.isSpace
2626

2727
def skipMarker(state: StateBlock, line: int):
2828
"""Search `[:~][\n ]`, returns next pos after marker on success or -1 on fail."""
@@ -51,7 +51,6 @@ def skipMarker(state: StateBlock, line: int):
5151
return start
5252

5353
def markTightParagraphs(state: StateBlock, idx: int):
54-
5554
level = state.level + 2
5655

5756
i = idx + 2
@@ -67,7 +66,6 @@ def markTightParagraphs(state: StateBlock, idx: int):
6766
i += 1
6867

6968
def deflist(state: StateBlock, startLine: int, endLine: int, silent: bool):
70-
7169
if silent:
7270
# quirk: validation mode validates a dd block only, not a whole deflist
7371
if state.ddIndent < 0:

‎mdit_py_plugins/dollarmath/index.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,7 @@ def dollarmath_plugin(
5454
# would be good to allow "proper" math rendering,
5555
# e.g. https://github.com/roniemartinez/latex2mathml
5656

57-
if renderer is None:
58-
_renderer = lambda content, _: escapeHtml(content)
59-
else:
60-
_renderer = renderer
57+
_renderer = lambda content, _: escapeHtml(content) if renderer is None else renderer
6158

6259
if label_renderer is None:
6360
_label_renderer = (
@@ -186,7 +183,7 @@ def _math_inline_dollar(state: StateInline, silent: bool) -> bool:
186183
continue
187184

188185
try:
189-
if is_double and not state.srcCharCode[end + 1] == 0x24:
186+
if is_double and state.srcCharCode[end + 1] != 0x24:
190187
pos = end + 1
191188
continue
192189
except IndexError:
@@ -253,7 +250,6 @@ def math_block_dollar(
253250
def _math_block_dollar(
254251
state: StateBlock, startLine: int, endLine: int, silent: bool
255252
) -> bool:
256-
257253
# TODO internal backslash escaping
258254

259255
haveEndMarker = False
@@ -280,7 +276,6 @@ def _math_block_dollar(
280276
# search for end of block on same line
281277
lineText = state.src[startPos:end]
282278
if len(lineText.strip()) > 3:
283-
284279
if lineText.strip().endswith("$$"):
285280
haveEndMarker = True
286281
end = end - 2 - (len(lineText) - len(lineText.strip()))

‎mdit_py_plugins/field_list/__init__.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,7 @@ def _fieldlist_rule(state: StateBlock, startLine: int, endLine: int, silent: boo
114114
nextLine = startLine
115115

116116
with set_parent_type(state, "fieldlist"):
117-
118117
while nextLine < endLine:
119-
120118
# create name tokens
121119
token = state.push("fieldlist_name_open", "dt", 1)
122120
token.map = [startLine, startLine]
@@ -151,12 +149,9 @@ def _fieldlist_rule(state: StateBlock, startLine: int, endLine: int, silent: boo
151149
contentStart = pos
152150

153151
# set indent for body text
154-
if contentStart >= maximum:
155-
# no body on first line, so use constant indentation
156-
# TODO adapt to indentation of subsequent lines?
157-
indent = 2
158-
else:
159-
indent = offset
152+
# no body on first line, so use constant indentation
153+
# TODO adapt to indentation of subsequent lines?
154+
indent = 2 if contentStart >= maximum else offset
160155

161156
# Run subparser on the field body
162157
token = state.push("fieldlist_body_open", "dd", 1)

0 commit comments

Comments
 (0)