-
Couldn't load subscription status.
- Fork 1.6k
Open
Labels
previewRelated to preview mode featuresRelated to preview mode featuresruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
Summary
f-string-in-get-text-func-call (INT001), format-in-get-text-func-call (INT002), and printf-in-get-text-func-call (INT003) only check the first argument (singular) of ngettext but skip the second (plural). The reasons to avoid f-strings etc. in the first argument apply equally to the second. This is true whether or not ngettext is imported, and if so whether it is aliased. Example:
$ cat >int00.py <<'# EOF'
from gettext import ngettext
def f(n):
ngettext("one", f"{n}", n)
ngettext("one", "{}".format(n), n)
ngettext("one", "%d" % n, n)
# EOF
$ ruff --isolated check int00.py --select INT001,INT002,INT003
All checks passed!
$ sed '/import/d' int00.py | ruff --isolated check - --select INT001,INT002,INT003
All checks passed!
$ sed '/import/s/$/ as n_/; s/ngettext(/n_(/' int00.py | ruff --isolated check - --select INT001,INT002,INT003
All checks passed!Version
ruff 0.14.2 (83a3bc4 2025-10-23)
Metadata
Metadata
Assignees
Labels
previewRelated to preview mode featuresRelated to preview mode featuresruleImplementing or modifying a lint ruleImplementing or modifying a lint rule