From c4898b81d8f7f35bd57ea39229077d8c2ce48ee7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 16:38:20 +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/astral-sh/ruff-pre-commit: v0.15.20 → v0.16.0](https://github.com/astral-sh/ruff-pre-commit/compare/v0.15.20...v0.16.0) - [github.com/pre-commit/mirrors-mypy: v2.1.0 → v2.3.0](https://github.com/pre-commit/mirrors-mypy/compare/v2.1.0...v2.3.0) --- .pre-commit-config.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a2f3f00d..43448855 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -21,14 +21,14 @@ repos: - id: trailing-whitespace - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.20 + rev: v0.16.0 hooks: - id: ruff-check args: [--fix] - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: v2.1.0 + rev: v2.3.0 hooks: - id: mypy args: [--config-file=pyproject.toml] From 64382f1fce73ee0aa24d51dddadb1653279284a1 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 27 Jul 2026 16:38:32 +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 | 6 +++--- myst_parser/inventory.py | 4 ++-- myst_parser/mdit_to_docutils/base.py | 8 ++++---- myst_parser/mdit_to_docutils/sphinx_.py | 2 +- myst_parser/mdit_to_docutils/transforms.py | 2 +- myst_parser/parsers/directives.py | 2 +- myst_parser/parsers/docutils_.py | 2 +- myst_parser/parsers/options.py | 6 ++---- myst_parser/parsers/parse_html.py | 3 +-- myst_parser/parsers/sphinx_.py | 2 +- myst_parser/sphinx_ext/myst_refs.py | 8 ++++---- 11 files changed, 21 insertions(+), 24 deletions(-) diff --git a/myst_parser/_docs.py b/myst_parser/_docs.py index 95c8314e..454c3390 100644 --- a/myst_parser/_docs.py +++ b/myst_parser/_docs.py @@ -382,9 +382,9 @@ def run(self): ### MyST Lexer ### # TODO when some more work and testing, this should be made available publicly -from pygments import token # noqa: E402 -from pygments.lexer import bygroups, inherit, this, using # noqa: E402 -from pygments.lexers.markup import MarkdownLexer # noqa: E402 +from pygments import token +from pygments.lexer import bygroups, inherit, this, using +from pygments.lexers.markup import MarkdownLexer class MystLexer(MarkdownLexer): diff --git a/myst_parser/inventory.py b/myst_parser/inventory.py index e14ac30d..c142f959 100644 --- a/myst_parser/inventory.py +++ b/myst_parser/inventory.py @@ -411,7 +411,7 @@ def filter_string( def fetch_inventory( - uri: str, *, timeout: None | float = None, base_url: None | str = None + uri: str, *, timeout: float | None = None, base_url: str | None = None ) -> InventoryType: """Fetch an inventory from a URL or local path.""" if uri.startswith(("http://", "https://")): @@ -421,7 +421,7 @@ def fetch_inventory( return load(stream, base_url=base_url) -def inventory_cli(inputs: None | list[str] = None): +def inventory_cli(inputs: list[str] | None = None): """Command line interface for fetching and parsing an inventory.""" parser = argparse.ArgumentParser(description="Parse an inventory file.") parser.add_argument("uri", metavar="[URL|PATH]", help="URI of the inventory file") diff --git a/myst_parser/mdit_to_docutils/base.py b/myst_parser/mdit_to_docutils/base.py index 68cfae72..7319fe28 100644 --- a/myst_parser/mdit_to_docutils/base.py +++ b/myst_parser/mdit_to_docutils/base.py @@ -112,7 +112,7 @@ def __init__(self, parser: MarkdownIt) -> None: if k.startswith("render_") and k != "render_children" } # these are lazy loaded, when needed - self._inventories: None | dict[str, inventory.InventoryType] = None + self._inventories: dict[str, inventory.InventoryType] | None = None def __getattr__(self, name: str): """Warn when the renderer has not been setup yet.""" @@ -300,7 +300,7 @@ def nested_render_text( text: str, lineno: int, inline: bool = False, - temp_root_node: None | nodes.Element = None, + temp_root_node: nodes.Element | None = None, heading_offset: int = 0, ) -> None: """Render unparsed text (appending to the current node). @@ -988,7 +988,7 @@ def render_link(self, token: SyntaxTreeNode) -> None: return self.render_link_unknown(token) def render_link_url( - self, token: SyntaxTreeNode, conversion: None | UrlSchemeType = None + self, token: SyntaxTreeNode, conversion: UrlSchemeType | None = None ) -> None: """Render link token (including autolink and linkify), where the link has been identified as an external URL. @@ -2113,7 +2113,7 @@ def default_slugify(title: str) -> str: def compute_unique_slug( token_tree: SyntaxTreeNode, slugs: Container[str], - slug_func: None | Callable[[str], str] = None, + slug_func: Callable[[str], str] | None = None, ) -> str: """Compute the slug for a heading token, unique against existing slugs.""" slug_func = github_slugify if slug_func is None else slug_func diff --git a/myst_parser/mdit_to_docutils/sphinx_.py b/myst_parser/mdit_to_docutils/sphinx_.py index 1569131f..21578cad 100644 --- a/myst_parser/mdit_to_docutils/sphinx_.py +++ b/myst_parser/mdit_to_docutils/sphinx_.py @@ -136,7 +136,7 @@ def render_link_unknown(self, token: SyntaxTreeNode) -> None: path_dest, *_path_ids = destination.split("#", maxsplit=1) path_id = _path_ids[0] if _path_ids else None - potential_path: None | Path = None + potential_path: Path | None = None if self.sphinx_env.srcdir: # not set in some test situations _, path_str = self.sphinx_env.relfn2path(path_dest, self.sphinx_env.docname) potential_path = Path(path_str) diff --git a/myst_parser/mdit_to_docutils/transforms.py b/myst_parser/mdit_to_docutils/transforms.py index a7f9427d..f7f346c6 100644 --- a/myst_parser/mdit_to_docutils/transforms.py +++ b/myst_parser/mdit_to_docutils/transforms.py @@ -218,7 +218,7 @@ def apply(self, **kwargs: t.Any) -> None: # gather explicit references # this follows the same logic as Sphinx's StandardDomain.process_doc - explicit: dict[str, tuple[str, None | str]] = {} + explicit: dict[str, tuple[str, str | None]] = {} for name, is_explicit in self.document.nametypes.items(): if not is_explicit: continue diff --git a/myst_parser/parsers/directives.py b/myst_parser/parsers/directives.py index 61c4d524..5dbfdf92 100644 --- a/myst_parser/parsers/directives.py +++ b/myst_parser/parsers/directives.py @@ -198,7 +198,7 @@ def _parse_directive_options( :param additional_options: Additional options for the directive, which the options block takes priority over """ - options_block: None | str = None + options_block: str | None = None options_position: int | None = None """The 1-based source line of the first line of the options block.""" if content.startswith("---"): diff --git a/myst_parser/parsers/docutils_.py b/myst_parser/parsers/docutils_.py index 177a7f50..315d7ee4 100644 --- a/myst_parser/parsers/docutils_.py +++ b/myst_parser/parsers/docutils_.py @@ -321,7 +321,7 @@ def parse(self, inputstring: str, document: nodes.document) -> None: pass # this will be reported during the render else: if topmatter: - warning = lambda wtype, msg: create_warning( # noqa: E731 + warning = lambda wtype, msg: create_warning( document, msg, wtype, line=1, append_to=document ) config = merge_file_level(config, topmatter, warning) diff --git a/myst_parser/parsers/options.py b/myst_parser/parsers/options.py index c904074f..d461402f 100644 --- a/myst_parser/parsers/options.py +++ b/myst_parser/parsers/options.py @@ -530,8 +530,7 @@ def _scan_block_scalar( # Determine the indentation level and go to the first non-empty line. min_indent = indent + 1 - if min_indent < 1: - min_indent = 1 + min_indent = max(min_indent, 1) if increment is None: breaks, max_indent, end_mark = _scan_block_scalar_indentation(stream) indent = max(min_indent, max_indent) @@ -652,8 +651,7 @@ def _scan_block_scalar_indentation( end_mark = stream.get_position() else: stream.forward() - if stream.column > max_indent: - max_indent = stream.column + max_indent = max(max_indent, stream.column) return chunks, max_indent, end_mark diff --git a/myst_parser/parsers/parse_html.py b/myst_parser/parsers/parse_html.py index d3b0c128..cea99cc0 100644 --- a/myst_parser/parsers/parse_html.py +++ b/myst_parser/parsers/parse_html.py @@ -25,7 +25,6 @@ from collections import abc, deque from collections.abc import Callable, Iterable, Iterator from html.parser import HTMLParser -from typing import Any class Attribute(dict): @@ -138,7 +137,7 @@ def render( def __str__(self) -> str: return self.render() - def __eq__(self, item: Any) -> bool: + def __eq__(self, item: object) -> bool: return item is self def walk(self, include_self: bool = False) -> Iterator[Element]: diff --git a/myst_parser/parsers/sphinx_.py b/myst_parser/parsers/sphinx_.py index 60035284..e08ebfe3 100644 --- a/myst_parser/parsers/sphinx_.py +++ b/myst_parser/parsers/sphinx_.py @@ -77,7 +77,7 @@ def parse(self, inputstring: str, document: nodes.document) -> None: pass # this will be reported during the render else: if topmatter: - warning = lambda wtype, msg: create_warning( # noqa: E731 + warning = lambda wtype, msg: create_warning( document, msg, wtype, line=1, append_to=document ) config = merge_file_level(config, topmatter, warning) diff --git a/myst_parser/sphinx_ext/myst_refs.py b/myst_parser/sphinx_ext/myst_refs.py index bdb89b54..49af6a36 100644 --- a/myst_parser/sphinx_ext/myst_refs.py +++ b/myst_parser/sphinx_ext/myst_refs.py @@ -37,7 +37,7 @@ class MystReferenceResolver(ReferencesResolver): default_priority = 9 # higher priority than ReferencesResolver (10) def log_warning( - self, target: None | str, msg: str, subtype: MystWarnings, **kwargs: Any + self, target: str | None, msg: str, subtype: MystWarnings, **kwargs: Any ): """Log a warning, with a myst type and specific subtype.""" @@ -80,7 +80,7 @@ def run(self, **kwargs: Any) -> None: contnode = cast(nodes.TextElement, node[0].deepcopy()) target = node["reftarget"] refdoc = node.get("refdoc", self.env.docname) - search_domains: None | list[str] = self.env.config.myst_ref_domains + search_domains: list[str] | None = self.env.config.myst_ref_domains # try to resolve the reference within the local project, # this asks all domains to resolve the reference, @@ -233,7 +233,7 @@ def resolve_myst_ref_any( refdoc: str, node: pending_xref, contnode: Element, - only_domains: None | list[str], + only_domains: list[str] | None, ) -> Element | None: """Resolve reference generated by the "myst" role; ``[text](#reference)``. @@ -393,7 +393,7 @@ def _resolve_myst_ref_intersphinx( contnode: nodes.Element, target: str, only_domains: list[str] | None, - ) -> None | nodes.reference: + ) -> nodes.reference | None: """Resolve a myst reference to an intersphinx inventory.""" matches = [ m