From 615c3341dc60877ac0a83a452861fa15f1d15ede Mon Sep 17 00:00:00 2001 From: correctmost <134317971+correctmost@users.noreply.github.com> Date: Fri, 24 Jul 2026 18:01:39 -0400 Subject: [PATCH] Enable flake8-gettext checks in ruff (#4664) This will help catch incorrect translation placeholders, like those fixed in commit dccd0c8cc. This commit also removes custom checking code from the locales_generator.sh script. --- archinstall/locales/locales_generator.sh | 10 ---------- pyproject.toml | 15 +++++++++++---- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/archinstall/locales/locales_generator.sh b/archinstall/locales/locales_generator.sh index 90818eb4..57be3b37 100755 --- a/archinstall/locales/locales_generator.sh +++ b/archinstall/locales/locales_generator.sh @@ -67,19 +67,9 @@ cmd_check_po_syntax() { echo "All .po files passed syntax check." } -cmd_check_no_tr_fstring() { - echo "Checking for tr(f-string) anti-pattern..." - if grep -rnE "tr\(\s*f['\"]" . --include='*.py'; then - echo "ERROR: use tr('...{}').format(...) instead of tr(f'...')" >&2 - return 1 - fi - echo "No tr(f-string) anti-pattern found." -} - cmd_check() { local failed=0 cmd_check_po_syntax || failed=1 - cmd_check_no_tr_fstring || failed=1 if [ "$failed" -eq 1 ]; then echo "Some translation checks failed." >&2 exit 1 diff --git a/pyproject.toml b/pyproject.toml index 9c047fad..4edba1c0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -202,9 +202,6 @@ indent-style = "tab" quote-style = "single" docstring-code-format = true -[tool.ruff.lint.flake8-tidy-imports] -ban-relative-imports = "all" - [tool.ruff.lint] select = [ "ASYNC", # flake8-async @@ -220,6 +217,7 @@ select = [ "G", # flake8-logging-format "I", # isort "ICN", # flake8-import-conventions + "INT", # flake8-gettext "ISC", # flake8-implicit-str-concat "LOG", # flake8-logging "PGH", # pygrep-hooks @@ -232,10 +230,10 @@ select = [ "RUF", # Ruff-specific rules "SLOT", # flake8-slot "T10", # flake8-debugger + "TID", # flake8-tidy-imports (Enables TID252) "UP", # pyupgrade "W", # pycodestyle warnings "YTT", # flake8-2020 - "TID", # flake8-tidy-imports (Enables TID252) ] ignore = [ @@ -256,5 +254,14 @@ ignore = [ "W191", # tab-indentation ] +[tool.ruff.lint.flake8-gettext] +function-names = [ + "tr", + "tr_noop", +] + +[tool.ruff.lint.flake8-tidy-imports] +ban-relative-imports = "all" + [tool.ruff.lint.mccabe] max-complexity = 40