From 4fcece0899a37db44787129ec647f87e81173332 Mon Sep 17 00:00:00 2001
From: Chris Sewell
Date: Thu, 27 Nov 2025 20:52:16 +0100
Subject: [PATCH 1/4] =?UTF-8?q?=F0=9F=94=A7=20Update=20pre-commit?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.pre-commit-config.yaml | 8 ++++----
myst_parser/_docs.py | 2 +-
myst_parser/config/main.py | 5 ++---
myst_parser/mdit_to_docutils/base.py | 15 +++++++--------
myst_parser/mdit_to_docutils/sphinx_.py | 6 ++----
myst_parser/mocking.py | 3 +--
myst_parser/parsers/docutils_.py | 8 ++++----
myst_parser/sphinx_ext/main.py | 2 +-
8 files changed, 22 insertions(+), 27 deletions(-)
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 0504ee84..8097ec15 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -13,7 +13,7 @@ exclude: >
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
- rev: v5.0.0
+ rev: v6.0.0
hooks:
- id: check-json
- id: check-yaml
@@ -21,14 +21,14 @@ repos:
- id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit
- rev: v0.8.4
+ rev: v0.14.6
hooks:
- - id: ruff
+ - id: ruff-check
args: [--fix]
- id: ruff-format
- repo: https://github.com/pre-commit/mirrors-mypy
- rev: v1.14.0
+ rev: v1.18.2
hooks:
- id: mypy
args: [--config-file=pyproject.toml]
diff --git a/myst_parser/_docs.py b/myst_parser/_docs.py
index 41212e98..95c8314e 100644
--- a/myst_parser/_docs.py
+++ b/myst_parser/_docs.py
@@ -211,7 +211,7 @@ def run(self):
:Name: `{name}`
:Description: {content}
:Arguments: {klass.required_arguments} required, {klass.optional_arguments} optional
-:Content: {'yes' if klass.has_content else 'no'}
+:Content: {"yes" if klass.has_content else "no"}
:Options:
"""
if klass.option_spec:
diff --git a/myst_parser/config/main.py b/myst_parser/config/main.py
index 2b088b56..275c8e7a 100644
--- a/myst_parser/config/main.py
+++ b/myst_parser/config/main.py
@@ -64,7 +64,7 @@ def check_url_schemes(inst: "MdParserConfig", field: dc.Field, value: Any) -> No
if isinstance(value, list | tuple):
if not all(isinstance(v, str) for v in value):
raise TypeError(f"'{field.name}' is not a list of strings: {value!r}")
- value = {v: None for v in value}
+ value = dict.fromkeys(value)
if not isinstance(value, dict):
raise TypeError(f"'{field.name}' is not a dictionary: {value!r}")
@@ -522,8 +522,7 @@ def merge_file_level(
if "html_meta" in topmatter:
warning(
MystWarnings.MD_TOPMATTER,
- "top-level 'html_meta' key is deprecated, "
- "place under 'myst' key instead",
+ "top-level 'html_meta' key is deprecated, place under 'myst' key instead",
)
updates["html_meta"] = topmatter["html_meta"]
if "substitutions" in topmatter:
diff --git a/myst_parser/mdit_to_docutils/base.py b/myst_parser/mdit_to_docutils/base.py
index 3778dd31..a17b423c 100644
--- a/myst_parser/mdit_to_docutils/base.py
+++ b/myst_parser/mdit_to_docutils/base.py
@@ -976,8 +976,7 @@ def render_link_path(self, token: SyntaxTreeNode) -> None:
def render_link_project(self, token: SyntaxTreeNode) -> None:
"""Render a link token like ``."""
destination = cast(str, token.attrGet("href") or "")
- if destination.startswith("project:"):
- destination = destination[8:]
+ destination = destination.removeprefix("project:")
if destination.startswith("#"):
return self.render_link_anchor(token, destination)
self.create_warning(
@@ -1796,13 +1795,13 @@ def run_directive(
)
return [error_msg]
- assert isinstance(
- result, list
- ), f'Directive "{name}" must return a list of nodes.'
+ assert isinstance(result, list), (
+ f'Directive "{name}" must return a list of nodes.'
+ )
for i in range(len(result)):
- assert isinstance(
- result[i], nodes.Node
- ), f'Directive "{name}" returned non-Node object (index {i}): {result[i]}'
+ assert isinstance(result[i], nodes.Node), (
+ f'Directive "{name}" returned non-Node object (index {i}): {result[i]}'
+ )
return result
def render_substitution_inline(self, token: SyntaxTreeNode) -> None:
diff --git a/myst_parser/mdit_to_docutils/sphinx_.py b/myst_parser/mdit_to_docutils/sphinx_.py
index b9b29225..1569131f 100644
--- a/myst_parser/mdit_to_docutils/sphinx_.py
+++ b/myst_parser/mdit_to_docutils/sphinx_.py
@@ -72,8 +72,7 @@ def _handle_relative_docs(self, destination: str) -> str:
def render_link_project(self, token: SyntaxTreeNode) -> None:
destination = cast(str, token.attrGet("href") or "")
- if destination.startswith("project:"):
- destination = destination[8:]
+ destination = destination.removeprefix("project:")
if destination.startswith("#"):
return self.render_link_anchor(token, destination)
@@ -108,8 +107,7 @@ def render_link_project(self, token: SyntaxTreeNode) -> None:
def render_link_path(self, token: SyntaxTreeNode) -> None:
destination = self.md.normalizeLinkText(cast(str, token.attrGet("href") or ""))
- if destination.startswith("path:"):
- destination = destination[5:]
+ destination = destination.removeprefix("path:")
destination = self._handle_relative_docs(destination)
explicit = (token.info != "auto") and (len(token.children or []) > 0)
wrap_node = addnodes.download_reference(
diff --git a/myst_parser/mocking.py b/myst_parser/mocking.py
index 61a2b172..8a800bcc 100644
--- a/myst_parser/mocking.py
+++ b/myst_parser/mocking.py
@@ -461,8 +461,7 @@ def run(self) -> list[nodes.Element]:
3, ":number-lines: with non-integer start value"
) from err
endline = startline + len(file_content.splitlines())
- if file_content.endswith("\n"):
- file_content = file_content[:-1]
+ file_content = file_content.removesuffix("\n")
tokens = NumberLines([([], file_content)], startline, endline)
for classes, value in tokens:
if classes:
diff --git a/myst_parser/parsers/docutils_.py b/myst_parser/parsers/docutils_.py
index e17de44b..2174175c 100644
--- a/myst_parser/parsers/docutils_.py
+++ b/myst_parser/parsers/docutils_.py
@@ -116,7 +116,7 @@ def _validate_url_schemes(
except Exception as err:
raise ValueError("Invalid YAML string") from err
if isinstance(output, str):
- output = {k: None for k in output.split(",")}
+ output = dict.fromkeys(output.split(","))
if not isinstance(output, dict):
raise ValueError("Expecting a comma-delimited str or YAML dictionary")
return output
@@ -278,7 +278,7 @@ def parse(self, inputstring: str, document: nodes.document) -> None:
for i, line in enumerate(inputstring.split("\n")):
if len(line) > document.settings.line_length_limit:
error = document.reporter.error(
- f"Line {i+1} exceeds the line-length-limit:"
+ f"Line {i + 1} exceeds the line-length-limit:"
f" {document.settings.line_length_limit}."
)
document.append(error)
@@ -479,7 +479,7 @@ def visit_rubric_html(self, node):
So here we override the visit/depart methods to output the correct element
"""
if "level" in node:
- self.body.append(self.starttag(node, f'h{node["level"]}', "", CLASS="rubric"))
+ self.body.append(self.starttag(node, f"h{node['level']}", "", CLASS="rubric"))
else:
self.body.append(self.starttag(node, "p", "", CLASS="rubric"))
@@ -490,7 +490,7 @@ def depart_rubric_html(self, node):
See explanation in `visit_rubric_html`
"""
if "level" in node:
- self.body.append(f'\n')
+ self.body.append(f"\n")
else:
self.body.append("
\n")
diff --git a/myst_parser/sphinx_ext/main.py b/myst_parser/sphinx_ext/main.py
index eda129ac..f3fe0f4a 100644
--- a/myst_parser/sphinx_ext/main.py
+++ b/myst_parser/sphinx_ext/main.py
@@ -70,7 +70,7 @@ def setup_sphinx(app: Sphinx, load_parser: bool = False) -> None:
for name, default, field in MdParserConfig().as_triple():
if "sphinx" not in field.metadata.get("omit", []):
# TODO add types?
- app.add_config_value(f"myst_{name}", default, "env", types=Any) # type: ignore[arg-type]
+ app.add_config_value(f"myst_{name}", default, "env", types=Any)
app.connect("builder-inited", create_myst_config)
app.connect("builder-inited", override_mathjax)
From f1b2c6b902ee89afe50c64a37acfcbfde60b5898 Mon Sep 17 00:00:00 2001
From: Chris Sewell
Date: Thu, 27 Nov 2025 21:00:59 +0100
Subject: [PATCH 2/4] Update tests.yml
---
.github/workflows/tests.yml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index a49f4c4b..3a0cdc90 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -31,10 +31,10 @@ jobs:
include:
- os: ubuntu-latest
python-version: "3.10"
- sphinx: ">=7,<8"
+ sphinx: ">=7,<8.2"
- os: windows-latest
python-version: "3.10"
- sphinx: ">=7,<8"
+ sphinx: ">=7,<8.2"
runs-on: ${{ matrix.os }}
From 3f4c1de855ec2d50f52d598ad3f6dd7eca1f5b98 Mon Sep 17 00:00:00 2001
From: Chris Sewell
Date: Thu, 27 Nov 2025 21:02:46 +0100
Subject: [PATCH 3/4] Update tests.yml
---
.github/workflows/tests.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 3a0cdc90..f668ed51 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -26,15 +26,15 @@ jobs:
fail-fast: false
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
- sphinx: [">=8,<9"]
+ sphinx: [">=8,<8.2"]
os: [ubuntu-latest]
include:
- os: ubuntu-latest
python-version: "3.10"
- sphinx: ">=7,<8.2"
+ sphinx: ">=7,<8"
- os: windows-latest
python-version: "3.10"
- sphinx: ">=7,<8.2"
+ sphinx: ">=7,<8"
runs-on: ${{ matrix.os }}
From a27913916f8bbbab7d33ff03f6bbae3a32bd0379 Mon Sep 17 00:00:00 2001
From: Chris Sewell
Date: Thu, 27 Nov 2025 21:08:09 +0100
Subject: [PATCH 4/4] Update conf.py
---
docs/conf.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/docs/conf.py b/docs/conf.py
index fb3843b9..2fc9589d 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -200,6 +200,8 @@
"https://www.sphinx-doc.org/en/master",
"https://markdown-it-py.readthedocs.io/en/latest",
]
+# TODO failing
+tippy_enable_wikitips = False
# -- LaTeX output -------------------------------------------------