From 5f6457911d5fe34bfed03014c0fe8f7b2f145417 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Thu, 2 Jan 2025 23:09:55 +0000 Subject: [PATCH] Enable the RUF048 lint in Ruff --- .ruff.toml | 2 +- sphinx/highlighting.py | 2 +- tests/test_highlighting.py | 2 +- tests/test_util/test_util_i18n.py | 3 --- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/.ruff.toml b/.ruff.toml index da6627854c..ec993e36e4 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -264,7 +264,7 @@ select = [ "RUF041", # Unnecessary nested `Literal` "RUF043", # Pattern passed to `match=` contains metacharacters but is neither escaped nor raw "RUF046", # Value being casted is already an integer -# "RUF048", # `__version__` may contain non-integral-like elements + "RUF048", # `__version__` may contain non-integral-like elements "RUF055", # Plain string pattern passed to `re` function # "RUF100", # Unused `noqa` directive "RUF101", # `{original}` is a redirect to `{target}` diff --git a/sphinx/highlighting.py b/sphinx/highlighting.py index c7ae156689..0ca5ed48c5 100644 --- a/sphinx/highlighting.py +++ b/sphinx/highlighting.py @@ -31,7 +31,7 @@ if TYPE_CHECKING: from pygments.lexer import Lexer from pygments.style import Style -if tuple(map(int, pygments.__version__.split('.')))[:2] < (2, 18): +if tuple(map(int, pygments.__version__.split('.')[:2])) < (2, 18): from pygments.formatter import Formatter # NoQA: F811 Formatter.__class_getitem__ = classmethod(lambda cls, name: cls) # type: ignore[attr-defined] diff --git a/tests/test_highlighting.py b/tests/test_highlighting.py index c32c1887eb..91f887633d 100644 --- a/tests/test_highlighting.py +++ b/tests/test_highlighting.py @@ -12,7 +12,7 @@ from pygments.token import Name, Text from sphinx.highlighting import PygmentsBridge -if tuple(map(int, pygments.__version__.split('.')))[:2] < (2, 18): +if tuple(map(int, pygments.__version__.split('.')[:2]))[:2] < (2, 18): from pygments.formatter import Formatter Formatter.__class_getitem__ = classmethod(lambda cls, name: cls) # type: ignore[attr-defined] diff --git a/tests/test_util/test_util_i18n.py b/tests/test_util/test_util_i18n.py index b6e865c331..4cb58fd46a 100644 --- a/tests/test_util/test_util_i18n.py +++ b/tests/test_util/test_util_i18n.py @@ -7,15 +7,12 @@ import os import time from pathlib import Path -import babel import pytest from babel.messages.mofile import read_mo from sphinx.errors import SphinxError from sphinx.util import i18n -BABEL_VERSION = tuple(map(int, babel.__version__.split('.'))) - def test_catalog_info_for_file_and_path(): cat = i18n.CatalogInfo('path', 'domain', 'utf-8')