From fd8ce84582e676a1d0eaebfafcb83f348535f9cc Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Mon, 13 Jan 2025 23:40:26 +0000 Subject: [PATCH] Enable the RUF001 lint in Ruff --- .ruff.toml | 4 ++-- sphinx/util/texescape.py | 6 +++--- sphinx/writers/texinfo.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.ruff.toml b/.ruff.toml index 0cde1e81e9..2cc4145ed9 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -70,7 +70,6 @@ ignore = [ "UP031", # Use format specifiers instead of percent format "UP032", # Use f-string instead of `format` call # Ruff-specific rules ('RUF') - "RUF001", # String contains ambiguous {}. Did you mean {}? "RUF012", # Mutable class attributes should be annotated with `typing.ClassVar` "RUF021", # Parenthesize `a and b` expressions when chaining `and` and `or` together, to make the precedence clear "RUF022", # `__all__` is not sorted @@ -321,7 +320,7 @@ logger-objects = [ "sphinx/ext/autodoc/importer.py" = ["D402"] "sphinx/util/requests.py" = ["D402"] -"sphinx/search/*" = ["E501"] +"sphinx/search/*" = ["E501", "RUF001"] # whitelist ``token`` in date format parsing "sphinx/util/i18n.py" = ["S105"] @@ -334,6 +333,7 @@ logger-objects = [ "ANN", # tests don't need annotations "D402", "PLC1901", # whitelist comparisons to the empty string ('') + "RUF001", # ambiguous unicode character "S301", # allow use of ``pickle`` "S403", # allow use of ``pickle`` "T201", # whitelist ``print`` for tests diff --git a/sphinx/util/texescape.py b/sphinx/util/texescape.py index ba5acf4f9a..ce6555a308 100644 --- a/sphinx/util/texescape.py +++ b/sphinx/util/texescape.py @@ -29,8 +29,8 @@ tex_replacements = [ # map some special Unicode characters to similar ASCII ones # (even for Unicode LaTeX as may not be supported by OpenType font) ('⎽', r'\_'), - ('ℯ', r'e'), - ('ⅈ', r'i'), + ('ℯ', r'e'), # U+212F # NoQA: RUF001 + ('ⅈ', r'i'), # U+2148 # NoQA: RUF001 # Greek alphabet not escaped: pdflatex handles it via textalpha and inputenc # OHM SIGN U+2126 is handled by LaTeX textcomp package ] @@ -63,7 +63,7 @@ unicode_tex_replacements = [ ('±', r'\(\pm\)'), ('→', r'\(\rightarrow\)'), ('‣', r'\(\rightarrow\)'), - ('–', r'\textendash{}'), + ('\N{EN DASH}', r'\textendash{}'), # superscript ('⁰', r'\(\sp{\text{0}}\)'), ('¹', r'\(\sp{\text{1}}\)'), diff --git a/sphinx/writers/texinfo.py b/sphinx/writers/texinfo.py index 9995119b73..aaf4a3703c 100644 --- a/sphinx/writers/texinfo.py +++ b/sphinx/writers/texinfo.py @@ -1503,7 +1503,7 @@ class TexinfoTranslator(SphinxTranslator): self.first_param = 0 text = self.escape(node.astext()) # replace no-break spaces with normal ones - text = text.replace(' ', '@w{ }') + text = text.replace('\N{NO-BREAK SPACE}', '@w{ }') self.body.append(text) raise nodes.SkipNode