Skip to content

Commit 5dda664

Browse files
authored
🔧 Update pre-commit (#1058)
1 parent 8a44f5d commit 5dda664

10 files changed

Lines changed: 25 additions & 28 deletions

File tree

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
fail-fast: false
2727
matrix:
2828
python-version: ["3.10", "3.11", "3.12", "3.13"]
29-
sphinx: [">=8,<9"]
29+
sphinx: [">=8,<8.2"]
3030
os: [ubuntu-latest]
3131
include:
3232
- os: ubuntu-latest

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ exclude: >
1313
repos:
1414

1515
- repo: https://github.com/pre-commit/pre-commit-hooks
16-
rev: v5.0.0
16+
rev: v6.0.0
1717
hooks:
1818
- id: check-json
1919
- id: check-yaml
2020
- id: end-of-file-fixer
2121
- id: trailing-whitespace
2222

2323
- repo: https://github.com/astral-sh/ruff-pre-commit
24-
rev: v0.8.4
24+
rev: v0.14.6
2525
hooks:
26-
- id: ruff
26+
- id: ruff-check
2727
args: [--fix]
2828
- id: ruff-format
2929

3030
- repo: https://github.com/pre-commit/mirrors-mypy
31-
rev: v1.14.0
31+
rev: v1.18.2
3232
hooks:
3333
- id: mypy
3434
args: [--config-file=pyproject.toml]

docs/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,8 @@
200200
"https://www.sphinx-doc.org/en/master",
201201
"https://markdown-it-py.readthedocs.io/en/latest",
202202
]
203+
# TODO failing
204+
tippy_enable_wikitips = False
203205

204206
# -- LaTeX output -------------------------------------------------
205207

myst_parser/_docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def run(self):
211211
:Name: `{name}`
212212
:Description: {content}
213213
:Arguments: {klass.required_arguments} required, {klass.optional_arguments} optional
214-
:Content: {'yes' if klass.has_content else 'no'}
214+
:Content: {"yes" if klass.has_content else "no"}
215215
:Options:
216216
"""
217217
if klass.option_spec:

myst_parser/config/main.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def check_url_schemes(inst: "MdParserConfig", field: dc.Field, value: Any) -> No
6464
if isinstance(value, list | tuple):
6565
if not all(isinstance(v, str) for v in value):
6666
raise TypeError(f"'{field.name}' is not a list of strings: {value!r}")
67-
value = {v: None for v in value}
67+
value = dict.fromkeys(value)
6868

6969
if not isinstance(value, dict):
7070
raise TypeError(f"'{field.name}' is not a dictionary: {value!r}")
@@ -522,8 +522,7 @@ def merge_file_level(
522522
if "html_meta" in topmatter:
523523
warning(
524524
MystWarnings.MD_TOPMATTER,
525-
"top-level 'html_meta' key is deprecated, "
526-
"place under 'myst' key instead",
525+
"top-level 'html_meta' key is deprecated, place under 'myst' key instead",
527526
)
528527
updates["html_meta"] = topmatter["html_meta"]
529528
if "substitutions" in topmatter:

myst_parser/mdit_to_docutils/base.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -976,8 +976,7 @@ def render_link_path(self, token: SyntaxTreeNode) -> None:
976976
def render_link_project(self, token: SyntaxTreeNode) -> None:
977977
"""Render a link token like `<project:...>`."""
978978
destination = cast(str, token.attrGet("href") or "")
979-
if destination.startswith("project:"):
980-
destination = destination[8:]
979+
destination = destination.removeprefix("project:")
981980
if destination.startswith("#"):
982981
return self.render_link_anchor(token, destination)
983982
self.create_warning(
@@ -1796,13 +1795,13 @@ def run_directive(
17961795
)
17971796
return [error_msg]
17981797

1799-
assert isinstance(
1800-
result, list
1801-
), f'Directive "{name}" must return a list of nodes.'
1798+
assert isinstance(result, list), (
1799+
f'Directive "{name}" must return a list of nodes.'
1800+
)
18021801
for i in range(len(result)):
1803-
assert isinstance(
1804-
result[i], nodes.Node
1805-
), f'Directive "{name}" returned non-Node object (index {i}): {result[i]}'
1802+
assert isinstance(result[i], nodes.Node), (
1803+
f'Directive "{name}" returned non-Node object (index {i}): {result[i]}'
1804+
)
18061805
return result
18071806

18081807
def render_substitution_inline(self, token: SyntaxTreeNode) -> None:

myst_parser/mdit_to_docutils/sphinx_.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,7 @@ def _handle_relative_docs(self, destination: str) -> str:
7272

7373
def render_link_project(self, token: SyntaxTreeNode) -> None:
7474
destination = cast(str, token.attrGet("href") or "")
75-
if destination.startswith("project:"):
76-
destination = destination[8:]
75+
destination = destination.removeprefix("project:")
7776
if destination.startswith("#"):
7877
return self.render_link_anchor(token, destination)
7978

@@ -108,8 +107,7 @@ def render_link_project(self, token: SyntaxTreeNode) -> None:
108107

109108
def render_link_path(self, token: SyntaxTreeNode) -> None:
110109
destination = self.md.normalizeLinkText(cast(str, token.attrGet("href") or ""))
111-
if destination.startswith("path:"):
112-
destination = destination[5:]
110+
destination = destination.removeprefix("path:")
113111
destination = self._handle_relative_docs(destination)
114112
explicit = (token.info != "auto") and (len(token.children or []) > 0)
115113
wrap_node = addnodes.download_reference(

myst_parser/mocking.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,7 @@ def run(self) -> list[nodes.Element]:
461461
3, ":number-lines: with non-integer start value"
462462
) from err
463463
endline = startline + len(file_content.splitlines())
464-
if file_content.endswith("\n"):
465-
file_content = file_content[:-1]
464+
file_content = file_content.removesuffix("\n")
466465
tokens = NumberLines([([], file_content)], startline, endline)
467466
for classes, value in tokens:
468467
if classes:

myst_parser/parsers/docutils_.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def _validate_url_schemes(
116116
except Exception as err:
117117
raise ValueError("Invalid YAML string") from err
118118
if isinstance(output, str):
119-
output = {k: None for k in output.split(",")}
119+
output = dict.fromkeys(output.split(","))
120120
if not isinstance(output, dict):
121121
raise ValueError("Expecting a comma-delimited str or YAML dictionary")
122122
return output
@@ -278,7 +278,7 @@ def parse(self, inputstring: str, document: nodes.document) -> None:
278278
for i, line in enumerate(inputstring.split("\n")):
279279
if len(line) > document.settings.line_length_limit:
280280
error = document.reporter.error(
281-
f"Line {i+1} exceeds the line-length-limit:"
281+
f"Line {i + 1} exceeds the line-length-limit:"
282282
f" {document.settings.line_length_limit}."
283283
)
284284
document.append(error)
@@ -479,7 +479,7 @@ def visit_rubric_html(self, node):
479479
So here we override the visit/depart methods to output the correct <h> element
480480
"""
481481
if "level" in node:
482-
self.body.append(self.starttag(node, f'h{node["level"]}', "", CLASS="rubric"))
482+
self.body.append(self.starttag(node, f"h{node['level']}", "", CLASS="rubric"))
483483
else:
484484
self.body.append(self.starttag(node, "p", "", CLASS="rubric"))
485485

@@ -490,7 +490,7 @@ def depart_rubric_html(self, node):
490490
See explanation in `visit_rubric_html`
491491
"""
492492
if "level" in node:
493-
self.body.append(f'</h{node["level"]}>\n')
493+
self.body.append(f"</h{node['level']}>\n")
494494
else:
495495
self.body.append("</p>\n")
496496

myst_parser/sphinx_ext/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def setup_sphinx(app: Sphinx, load_parser: bool = False) -> None:
7070
for name, default, field in MdParserConfig().as_triple():
7171
if "sphinx" not in field.metadata.get("omit", []):
7272
# TODO add types?
73-
app.add_config_value(f"myst_{name}", default, "env", types=Any) # type: ignore[arg-type]
73+
app.add_config_value(f"myst_{name}", default, "env", types=Any)
7474

7575
app.connect("builder-inited", create_myst_config)
7676
app.connect("builder-inited", override_mathjax)

0 commit comments

Comments
 (0)