-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RUF027: false positive for gettext translation strings #10023
Labels
Comments
Makes sense, we’ll omit these. |
charliermarsh
added
bug
Something isn't working
good first issue
Good for newcomers
labels
Feb 18, 2024
Hey @charliermarsh, seems like a good issue for a newby in the ruff code base. I'd like to give it a shot. |
Go for it @robincaloudis! Thanks! |
Hey @charliermarsh, do you mind to review #10118? Thank you. |
charliermarsh
added a commit
that referenced
this issue
Feb 25, 2024
…#10118) ## Summary It is a convention to use the `_()` alias for `gettext()`. We want to avoid statement expressions and assignments related to aliases of the gettext API. See https://docs.python.org/3/library/gettext.html for details. When one uses `_() to mark a string for translation, the tools look for these markers and replace the original string with its translated counterpart. If the string contains variable placeholders or formatting, it can complicate the translation process, lead to errors or incorrect translations. ## Test Plan * Test file `RUF027_1.py` was extended such that the test reproduces the false-positive Closes #10023. --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
nkxxll
pushed a commit
to nkxxll/ruff
that referenced
this issue
Mar 10, 2024
…astral-sh#10118) ## Summary It is a convention to use the `_()` alias for `gettext()`. We want to avoid statement expressions and assignments related to aliases of the gettext API. See https://docs.python.org/3/library/gettext.html for details. When one uses `_() to mark a string for translation, the tools look for these markers and replace the original string with its translated counterpart. If the string contains variable placeholders or formatting, it can complicate the translation process, lead to errors or incorrect translations. ## Test Plan * Test file `RUF027_1.py` was extended such that the test reproduces the false-positive Closes astral-sh#10023. --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
is detected as
RUF027 Possible f-string without an "f" prefix
.I consider this false-positive, as strings in
_()
should never bef
strings or otherwise formatted.The text was updated successfully, but these errors were encountered: