Skip to content

Commit e76acea

Browse files
🔧 MAINTAIN: pre-commit autoupdate, pin ruff base rules (#138)
ruff v0.15.12 -> v0.17.4, mypy v1.20.2 -> v2.4.1. Pin ruff's base rule set to E4/E7/E9/F (ruff 0.16 grew its default set) and keep the existing extend-select/extend-ignore.
1 parent f4f4021 commit e76acea

7 files changed

Lines changed: 30 additions & 18 deletions

File tree

‎.pre-commit-config.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ repos:
2020
- id: trailing-whitespace
2121

2222
- repo: https://github.com/astral-sh/ruff-pre-commit
23-
rev: v0.15.12
23+
rev: v0.17.4
2424
hooks:
2525
- id: ruff
2626
args: [--fix]
2727
- id: ruff-format
2828

2929
- repo: https://github.com/pre-commit/mirrors-mypy
30-
rev: v1.20.2
30+
rev: v2.4.1
3131
hooks:
3232
- id: mypy
3333
additional_dependencies: [markdown-it-py~=3.0]

‎AGENTS.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ plugin_name/
215215
Plugins create and manipulate markdown-it tokens:
216216

217217
```python
218-
token = state.push("my_type_open", "div", 1) # Opening tag
218+
token = state.push("my_type_open", "div", 1) # Opening tag
219219
token.attrSet("class", "my-class")
220220
token.markup = "..."
221221
token.map = [startLine, nextLine]
@@ -302,6 +302,7 @@ print(md.render("Some $inline$ math"))
302302
```python
303303
from markdown_it import MarkdownIt
304304

305+
305306
def my_plugin(md: MarkdownIt) -> None:
306307
md.block.ruler.before("fence", "my_rule", _my_rule)
307308
md.add_render_rule("my_type", _render_my_type)
@@ -318,6 +319,7 @@ Block rules receive `(state: StateBlock, startLine: int, endLine: int, silent: b
318319
```python
319320
from markdown_it.rules_block import StateBlock
320321

322+
321323
def my_block_rule(
322324
state: StateBlock, startLine: int, endLine: int, silent: bool
323325
) -> bool:
@@ -348,6 +350,7 @@ Inline rules receive `(state: StateInline, silent: bool) -> bool`:
348350
```python
349351
from markdown_it.rules_inline import StateInline
350352

353+
351354
def my_inline_rule(state: StateInline, silent: bool) -> bool:
352355
if state.src[state.pos] != "$":
353356
return False

‎docs/index.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ These can be enabled individually:
1111

1212
```python
1313
from markdown_it import MarkdownIt
14-
md = MarkdownIt("commonmark").enable('table')
14+
15+
md = MarkdownIt("commonmark").enable("table")
1516
```
1617

1718
or as part of a configuration:
1819

1920
```python
2021
from markdown_it import MarkdownIt
22+
2123
md = MarkdownIt("gfm-like")
2224
```
2325

‎mdit_py_plugins/admon/index.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def admonition(state: StateBlock, startLine: int, endLine: int, silent: bool) ->
188188
return True
189189

190190

191-
def admon_plugin(md: MarkdownIt, render: None | Callable[..., str] = None) -> None:
191+
def admon_plugin(md: MarkdownIt, render: Callable[..., str] | None = None) -> None:
192192
"""Plugin to use
193193
`python-markdown style admonitions
194194
<https://python-markdown.github.io/extensions/admonition>`_.

‎mdit_py_plugins/container/index.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def container_plugin(
2121
md: MarkdownIt,
2222
name: str,
2323
marker: str = ":",
24-
validate: None | Callable[[str, str], bool] = None,
25-
render: None | Callable[..., str] = None,
24+
validate: Callable[[str, str], bool] | None = None,
25+
render: Callable[..., str] | None = None,
2626
) -> None:
2727
"""Plugin ported from
2828
`markdown-it-container <https://github.com/markdown-it/markdown-it-container>`__.

‎mdit_py_plugins/texmath/index.py‎

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class RuleDictType(_RuleDictReqType, total=False):
8686

8787
def applyRule(
8888
rule: RuleDictType, string: str, begin: int, inBlockquote: bool
89-
) -> None | Match[str]:
89+
) -> Match[str] | None:
9090
if not (
9191
string.startswith(rule["tag"], begin)
9292
and (rule["pre"](string, begin) if "pre" in rule else True)
@@ -210,14 +210,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
210210
{
211211
"name": "math_block_eqno",
212212
"rex": re.compile(
213-
r"^\\\[(((?!\\\]|\\\[)[\s\S])+?)\\\]\s*?\(([^)$\r\n]+?)\)", re.M
213+
r"^\\\[(((?!\\\]|\\\[)[\s\S])+?)\\\]\s*?\(([^)$\r\n]+?)\)",
214+
re.MULTILINE,
214215
),
215216
"tmpl": '<section class="eqno"><eqn>{0}</eqn><span>({1})</span></section>',
216217
"tag": "\\[",
217218
},
218219
{
219220
"name": "math_block",
220-
"rex": re.compile(r"^\\\[([\s\S]+?)\\\]", re.M),
221+
"rex": re.compile(r"^\\\[([\s\S]+?)\\\]", re.MULTILINE),
221222
"tmpl": "<section>\n<eqn>{0}</eqn>\n</section>\n",
222223
"tag": "\\[",
223224
},
@@ -237,15 +238,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
237238
"name": "math_block_eqno",
238239
"rex": re.compile(
239240
r"^`{3}math\s(\s*[^`\s](?:[^`]*[^`\s])?|\s)\s+`{3}\s*?\(([^)$\r\n]+?)\)",
240-
re.M,
241+
re.MULTILINE,
241242
),
242243
"tmpl": '<section class="eqno">\n<eqn>{0}</eqn><span>({1})</span>\n</section>\n',
243244
"tag": "```math",
244245
},
245246
{
246247
"name": "math_block",
247248
"rex": re.compile(
248-
r"^`{3}math\s(\s*[^`\s](?:[^`]*[^`\s])?|\s)\s+`{3}", re.M
249+
r"^`{3}math\s(\s*[^`\s](?:[^`]*[^`\s])?|\s)\s+`{3}", re.MULTILINE
249250
),
250251
"tmpl": "<section>\n<eqn>{0}</eqn>\n</section>\n",
251252
"tag": "```math",
@@ -282,15 +283,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
282283
"name": "math_block_eqno",
283284
"rex": re.compile(
284285
r"^`{3}math\s(\s*[^`\s](?:[^`]*[^`\s])?|\s)\s+`{3}\s*?\(([^)$\r\n]+?)\)",
285-
re.M,
286+
re.MULTILINE,
286287
),
287288
"tmpl": '<section class="eqno"><eqn>{0}</eqn><span>({1})</span></section>',
288289
"tag": "```math",
289290
},
290291
{
291292
"name": "math_block",
292293
"rex": re.compile(
293-
r"^`{3}math\s(\s*[^`\s](?:[^`]*[^`\s])?|\s)\s+`{3}", re.M
294+
r"^`{3}math\s(\s*[^`\s](?:[^`]*[^`\s])?|\s)\s+`{3}", re.MULTILINE
294295
),
295296
"tmpl": "<section><eqn>{0}</eqn></section>",
296297
"tag": "```math",
@@ -309,13 +310,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
309310
"block": [
310311
{
311312
"name": "math_block_eqno",
312-
"rex": re.compile(r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)", re.M),
313+
"rex": re.compile(
314+
r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)", re.MULTILINE
315+
),
313316
"tmpl": '<section class="eqno"><eqn>{0}</eqn><span>({1})</span></section>',
314317
"tag": "$$",
315318
},
316319
{
317320
"name": "math_block",
318-
"rex": re.compile(r"^\${2}([^$]*?)\${2}", re.M),
321+
"rex": re.compile(r"^\${2}([^$]*?)\${2}", re.MULTILINE),
319322
"tmpl": "<section><eqn>{0}</eqn></section>",
320323
"tag": "$$",
321324
},
@@ -343,13 +346,15 @@ def render(tex: str, displayMode: bool, macros: Any) -> str:
343346
"block": [
344347
{
345348
"name": "math_block_eqno",
346-
"rex": re.compile(r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)", re.M),
349+
"rex": re.compile(
350+
r"^\${2}([^$]*?)\${2}\s*?\(([^)$\r\n]+?)\)", re.MULTILINE
351+
),
347352
"tmpl": '<section class="eqno">\n<eqn>{0}</eqn><span>({1})</span>\n</section>\n',
348353
"tag": "$$",
349354
},
350355
{
351356
"name": "math_block",
352-
"rex": re.compile(r"^\${2}([^$]*?)\${2}", re.M),
357+
"rex": re.compile(r"^\${2}([^$]*?)\${2}", re.MULTILINE),
353358
"tmpl": "<section>\n<eqn>{0}</eqn>\n</section>\n",
354359
"tag": "$$",
355360
},

‎pyproject.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ exclude = [
5656
]
5757

5858
[tool.ruff.lint]
59+
# Pin the base rule set (ruff >=0.16 grew its default set); extend it deliberately below.
60+
select = ["E4", "E7", "E9", "F"]
5961
extend-select = [
6062
"B", # flake8-bugbear
6163
"C4", # flake8-comprehensions

0 commit comments

Comments
 (0)