From 86b26d2d56dd4d19c0bc3b0e24d7677160756f3f Mon Sep 17 00:00:00 2001 From: Johannes Maron Date: Sun, 11 Oct 2026 21:49:20 +0200 Subject: [PATCH 1/3] Update the Ruff configuration - Use the shared extend-select rule set, including D213 and S - Align the ignore list with the other projects --- pyproject.toml | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index e0f41dd..9185272 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,21 +67,27 @@ quote-style = "double" line-ending = "auto" skip-magic-trailing-comma = false [tool.ruff.lint] -select = [ - "D", # pydocstyle - "E", # pycodestyle errors - "EXE", # flake8-executable - "F", # pyflakes - "I", # isort - "PGH", # pygrep-hooks - "PT", # flake8-pytest-style - "RET", # flake8-return - "S", # flake8-bandit - "SIM", # flake8-simplify - "UP", # pyupgrade - "W", # pycodestyle warnings +extend-select = [ + "C90", + "D", + "D213", + "DJ", + "E", + "G", + "N", + "PERF", + "PT", + "PTH", + "RET", + "S", + "SIM", + "SLOT", + "T20", + "TRY", + "UP", + "W", ] -ignore = [ "D1" ] +ignore = [ "D1", "D203", "D212", "E501", "RUF01" ] per-file-ignores."*/migrations/*.py" = [ "E501" ] per-file-ignores."*/test*.py" = [ "PLR2004", "S101" ] flake8-pytest-style.fixture-parentheses = false From f281dabdf5e73a97738539f919d0f2079a1c6acb Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 11 Oct 2026 19:57:00 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- flit_gettext/core.py | 2 +- flit_gettext/scm.py | 4 ++-- tests/conftest.py | 3 ++- tests/test_core.py | 4 ++-- tests/test_scm.py | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/flit_gettext/core.py b/flit_gettext/core.py index 0507e23..edfd221 100644 --- a/flit_gettext/core.py +++ b/flit_gettext/core.py @@ -1,5 +1,5 @@ from flit_core import buildapi -from flit_core.buildapi import * # noqa: F403 +from flit_core.buildapi import * from flit_gettext.utils import compile_gettext_translations diff --git a/flit_gettext/scm.py b/flit_gettext/scm.py index f702fc3..db53498 100644 --- a/flit_gettext/scm.py +++ b/flit_gettext/scm.py @@ -1,5 +1,5 @@ # pragma: no cover # covered in integration test using subprocess -from flit_scm import * # noqa: F403 +from flit_scm import * -from .core import * # noqa: F403 +from .core import * diff --git a/tests/conftest.py b/tests/conftest.py index 5063146..cfc9840 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -11,7 +11,8 @@ def copy_backend(temp_dir): - """Copy the in-tree build backend into the package directory. + """ + Copy the in-tree build backend into the package directory. ``backend-path`` must point to a directory inside the project. """ diff --git a/tests/test_core.py b/tests/test_core.py index e678b9b..4806277 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -25,7 +25,7 @@ def test_build_sdist(package): """ ) - output = subprocess.check_output( # noqa: S603 + output = subprocess.check_output( [sys.executable, "-m", "build", "--sdist"], cwd=package, env={**os.environ, "PYTHONPATH": f".:{ROOT}"}, @@ -54,7 +54,7 @@ def test_build_wheel(package): """ ) - output = subprocess.check_output( # noqa: S603 + output = subprocess.check_output( [sys.executable, "-m", "build", "--wheel"], cwd=package, env={**os.environ, "PYTHONPATH": f".:{ROOT}"}, diff --git a/tests/test_scm.py b/tests/test_scm.py index 91a75f2..bf42006 100644 --- a/tests/test_scm.py +++ b/tests/test_scm.py @@ -25,7 +25,7 @@ def test_build_sdist(package_scm): """ ) - output = subprocess.check_output( # noqa: S603 + output = subprocess.check_output( [sys.executable, "-m", "build", "--sdist"], cwd=package_scm, env={**os.environ, "PYTHONPATH": f".:{ROOT}"}, @@ -54,7 +54,7 @@ def test_build_wheel(package_scm): """ ) - output = subprocess.check_output( # noqa: S603 + output = subprocess.check_output( [sys.executable, "-m", "build", "--wheel"], cwd=package_scm, env={**os.environ, "PYTHONPATH": f".:{ROOT}"}, From 0f30e32e4bfaf1c93662a07973d00c0b89fe0283 Mon Sep 17 00:00:00 2001 From: Johannes Maron Date: Mon, 12 Oct 2026 00:20:03 +0200 Subject: [PATCH 3/3] Fix the remaining Ruff violations - Scope the new rules to tests with per-file-ignores - Modernise the code the new rules flag, without changing behaviour --- flit_gettext/utils.py | 6 ++++-- pyproject.toml | 2 +- tests/test_core.py | 2 +- tests/test_scm.py | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/flit_gettext/utils.py b/flit_gettext/utils.py index 5f066b2..0916ee4 100644 --- a/flit_gettext/utils.py +++ b/flit_gettext/utils.py @@ -1,16 +1,18 @@ import shutil import subprocess # nosec +import sys from pathlib import Path def compile_gettext_translations(config): """Compile gettext translations.""" - print("\33[1m* Compiling gettext translations...\33[0m") + sys.stdout.write("\33[1m* Compiling gettext translations...\33[0m\n") msgfmt = shutil.which("msgfmt") if msgfmt is None: - raise OSError("msgfmt not found, please install gettext or check your PATH.") + msg = "msgfmt not found, please install gettext or check your PATH." + raise OSError(msg) # working directory is the source tree for file in Path().rglob(f"{config.module}/**/*.po"): diff --git a/pyproject.toml b/pyproject.toml index 9185272..f808291 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -89,7 +89,7 @@ extend-select = [ ] ignore = [ "D1", "D203", "D212", "E501", "RUF01" ] per-file-ignores."*/migrations/*.py" = [ "E501" ] -per-file-ignores."*/test*.py" = [ "PLR2004", "S101" ] +per-file-ignores."tests/**" = [ "DJ006", "DJ007", "DJ008", "PLR2004", "S101", "S105", "S106", "S311", "S603", "S607" ] flake8-pytest-style.fixture-parentheses = false flake8-pytest-style.mark-parentheses = false isort.combine-as-imports = true diff --git a/tests/test_core.py b/tests/test_core.py index 4806277..7fd3684 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -86,7 +86,7 @@ def test_editable_editable(package): packages_dir = package / "packages" packages_dir.mkdir(parents=True) - output = subprocess.check_output( # noqa: S603 + output = subprocess.check_output( [ sys.executable, "-m", diff --git a/tests/test_scm.py b/tests/test_scm.py index bf42006..24050da 100644 --- a/tests/test_scm.py +++ b/tests/test_scm.py @@ -86,7 +86,7 @@ def test_editable_editable(package_scm): packages_dir = package_scm / "packages" packages_dir.mkdir(parents=True) - output = subprocess.check_output( # noqa: S603 + output = subprocess.check_output( [ sys.executable, "-m",