Skip to content
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

PLR6104 rewrites numbers w/o the base indicator #11672

Open
Avasam opened this issue Jun 1, 2024 · 2 comments
Open

PLR6104 rewrites numbers w/o the base indicator #11672

Avasam opened this issue Jun 1, 2024 · 2 comments
Labels
fixes Related to suggested fixes for violations

Comments

@Avasam
Copy link

Avasam commented Jun 1, 2024

input

test = 0x5
test = test + 0xBA

test2 = b""
test2 = test2 + b"\000"

Run ruff check --fix --unsafe-fixes --preview --select=PLR6104 --isolated

output

test = 0x5
test += 186

test2 = b""
test2 += b"\x00"

Ruff version 0.4.7

@charliermarsh charliermarsh added the fixes Related to suggested fixes for violations label Jun 1, 2024
@charliermarsh
Copy link
Member

Yeah, common theme with Generator usage, we don't preserve verbatim numbers.

@dhruvmanila
Copy link
Member

Once #11457 is completed, this can be solved by including number related flags on TokenFlags, propagating it to the NumberLiteral node and using that in the Generator. This would be similar to the flags on the string nodes. This is actually one of the potential use-case me and Micha discussed for TokenFlags.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fixes Related to suggested fixes for violations
Projects
None yet
Development

No branches or pull requests

3 participants