We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
"%.2X" % 1
I know fixing UP031 is unsafe, but in this case we can do better:
"%.2X" % 1 is converted to "{:.2X}".format(1) but should probably be converted to "{:02X}".format(1)
"{:.2X}".format(1)
"{:02X}".format(1)
>>> "%.2X" % 1 '01' >>> "%02X" % 1 '01' >>> "{:02X}".format(1) '01' >>> "{:.2X}".format(1) Traceback (most recent call last): File "<stdin>", line 1, in <module> ValueError: Precision not allowed in integer format specifier
Command: ruff check --select UP031 --fix --unsafe-fixes test.py Ruff Version: 0.5.3
ruff check --select UP031 --fix --unsafe-fixes test.py
The text was updated successfully, but these errors were encountered:
Agreed.
Sorry, something went wrong.
So basically: use :0 rather than . for integer-only presentation types.
:0
.
Use colon rather than dot formatting for integer-only types (#12534)
425761e
## Summary Closes #12421.
charliermarsh
Successfully merging a pull request may close this issue.
I know fixing UP031 is unsafe, but in this case we can do better:
"%.2X" % 1
is converted to"{:.2X}".format(1)
but should probably be converted to"{:02X}".format(1)
Command:
ruff check --select UP031 --fix --unsafe-fixes test.py
Ruff Version: 0.5.3
The text was updated successfully, but these errors were encountered: