From d3d7fbb6a4fd2ecd12c7a29d7de902a869897eb9 Mon Sep 17 00:00:00 2001 From: Chris Sewell Date: Tue, 16 Jul 2024 10:20:24 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20pre-commit=20autoupdate=20(#946)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 4 ++-- myst_parser/_docs.py | 5 +---- myst_parser/inventory.py | 4 ++-- myst_parser/mdit_to_docutils/sphinx_.py | 2 +- myst_parser/parsers/options.py | 6 +++--- myst_parser/sphinx_ext/mathjax.py | 2 +- 6 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 28486afd..54da7ee0 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.4.1 + rev: v0.5.2 hooks: - id: ruff args: [--fix] - id: ruff-format - repo: https://github.com/pre-commit/mirrors-mypy - rev: v1.9.0 + rev: v1.10.1 hooks: - id: mypy args: [--config-file=pyproject.toml] diff --git a/myst_parser/_docs.py b/myst_parser/_docs.py index 197ad576..1f773934 100644 --- a/myst_parser/_docs.py +++ b/myst_parser/_docs.py @@ -96,10 +96,7 @@ def field_type(field): ftypes = ( get_args(field.type) if get_origin(field.type) is Union else [field.type] ) - ctype = " | ".join( - str("None" if ftype == type(None) else ftype) # type: ignore[comparison-overlap] - for ftype in ftypes - ) + ctype = " | ".join(str("None" if ftype is None else ftype) for ftype in ftypes) ctype = " ".join(ctype.splitlines()) ctype = ctype.replace("typing.", "") ctype = ctype.replace("typing_extensions.", "") diff --git a/myst_parser/inventory.py b/myst_parser/inventory.py index 4295a3aa..88e3ac4c 100644 --- a/myst_parser/inventory.py +++ b/myst_parser/inventory.py @@ -97,7 +97,7 @@ def load(stream: IO, base_url: str | None = None) -> InventoryType: elif line == "# Sphinx inventory version 2": return _load_v2(reader, base_url) else: - raise ValueError("invalid inventory header: %s" % line) + raise ValueError(f"invalid inventory header: {line}") def _load_v1(stream: InventoryFileReader, base_url: str | None) -> InventoryType: @@ -137,7 +137,7 @@ def _load_v2(stream: InventoryFileReader, base_url: str | None) -> InventoryType } line = stream.readline() if "zlib" not in line: - raise ValueError("invalid inventory header (not compressed): %s" % line) + raise ValueError(f"invalid inventory header (not compressed): {line}") for line in stream.read_compressed_lines(): # be careful to handle names with embedded spaces correctly diff --git a/myst_parser/mdit_to_docutils/sphinx_.py b/myst_parser/mdit_to_docutils/sphinx_.py index c138d0d9..4f141a69 100644 --- a/myst_parser/mdit_to_docutils/sphinx_.py +++ b/myst_parser/mdit_to_docutils/sphinx_.py @@ -235,7 +235,7 @@ def add_math_target(self, node: nodes.math_block) -> nodes.target: node["docname"] = self.sphinx_env.docname # create target node - node_id = nodes.make_id("equation-%s" % node["label"]) + node_id = nodes.make_id("equation-{}".format(node["label"])) target = nodes.target("", "", ids=[node_id]) self.document.note_explicit_target(target) return target diff --git a/myst_parser/parsers/options.py b/myst_parser/parsers/options.py index 366d4559..bfabf6d2 100644 --- a/myst_parser/parsers/options.py +++ b/myst_parser/parsers/options.py @@ -440,7 +440,7 @@ def _scan_flow_scalar_non_spaces( chunks.extend(_scan_flow_scalar_breaks(stream)) else: raise TokenizeError( - "found unknown escape character %r" % ch, + f"found unknown escape character {ch!r}", stream.get_position(), "while scanning a double-quoted scalar", start_mark, @@ -585,7 +585,7 @@ def _scan_block_scalar_indicators( ch = stream.peek() if ch not in _CHARS_END_SPACE_NEWLINE: raise TokenizeError( - "expected chomping or indentation indicators, but found %r" % ch, + f"expected chomping or indentation indicators, but found {ch!r}", stream.get_position(), "while scanning a block scalar", start_mark, @@ -605,7 +605,7 @@ def _scan_block_scalar_ignored_line( ch = stream.peek() if ch not in _CHARS_END_NEWLINE: raise TokenizeError( - "expected a comment or a line break, but found %r" % ch, + f"expected a comment or a line break, but found {ch!r}", stream.get_position(), "while scanning a block scalar", start_mark, diff --git a/myst_parser/sphinx_ext/mathjax.py b/myst_parser/sphinx_ext/mathjax.py index be425f1b..ec46e5b8 100644 --- a/myst_parser/sphinx_ext/mathjax.py +++ b/myst_parser/sphinx_ext/mathjax.py @@ -106,7 +106,7 @@ def html_visit_displaymath(self: HTMLTranslator, node: nodes.math_block) -> None ) if node["number"]: number = get_node_equation_number(self, node) - self.body.append('(%s)' % number) + self.body.append(f'({number})') self.add_permalink_ref(node, _("Permalink to this equation")) self.body.append("") prefix, suffix = self.builder.config.mathjax_display