From 6f91bab302971470f07c7858649ad1d133fb66bc Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 16:35:11 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/pre-commit/pre-commit-hooks: v5.0.0 → v6.0.0](https://github.com/pre-commit/pre-commit-hooks/compare/v5.0.0...v6.0.0) - [github.com/astral-sh/ruff-pre-commit: v0.8.4 → v0.13.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.4...v0.13.2) - [github.com/pre-commit/mirrors-mypy: v1.14.0 → v1.18.2](https://github.com/pre-commit/mirrors-mypy/compare/v1.14.0...v1.18.2) --- .pre-commit-config.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0504ee84..c43b1cef 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.13.2 hooks: - id: ruff 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] From ae8793b717d96b1e4cca5078b7bf01ca2a08f2d0 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 29 Sep 2025 16:35:23 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- 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 ++++---- 6 files changed, 17 insertions(+), 22 deletions(-) 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")