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
Add check for redundant u prefixed string in Python 3 #4102
Comments
This sound reasonable; maybe |
I was thinking about leaving the door open to check for f-strings without interpolation and maybe other cases.
For projects that have already been translated to Python 3, 2to3 is not very useful and I believe many would prefer to just remove the prefix manually once it's flagged by the linter. |
Ok, it makes sense for those that did not run 2to3 in the past. We already have a message for |
You can assign this to me. However, I would like to have #4787 first because I would include it in the |
This adds a checker for u-prefixes for strings, as used in Python 2. Closes pylint-dev#4102
Pylint 2.10 added new default checks [1]: redundant-u-string-prefix: Emitted when the u prefix is added to a string [1] https://pylint.pycqa.org/en/latest/whatsnew/2.10.html [2] pylint-dev/pylint#4102 Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Pylint 2.10 introduced new checker `redundant-u-string-prefix`: > Added redundant-u-string-prefix checker: Emitted when the u prefix is added to a string https://pylint.pycqa.org/en/latest/whatsnew/changelog.html#what-s-new-in-pylint-2-10-0 pylint-dev/pylint#4102 Fixes: freeipa#244 Signed-off-by: Stanislav Levin <slev@altlinux.org>
Is your feature request related to a problem? Please describe
In Python 3, the
u
prefix is no longer necessary to indicate that a string is unicode, but some programmers may put it there out of habit or because they copied the code from somewhere else.Describe the solution you'd like
Pylint should flag instances of u-prefixed strings in Python 3 with the
redundant-string-prefix
code.I can contribute this check if there is interest in it.
The text was updated successfully, but these errors were encountered: