-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationshelp wantedContributions especially welcomeContributions especially welcome
Description
Summary
The fix for native-literals (UP018) should add spaces between tokens as necessary to avoid syntax errors and other problems.
Reverted syntax error:
$ cat >up018_1.py <<'# EOF'
bool(True)and None
# EOF
$ ruff --isolated check up018_1.py --select UP018 --diff 2>&1 | grep error:
error: Fix introduced a syntax error. Reverting all changes.Runtime SyntaxWarnings:
$ cat >up018_2.py <<'# EOF'
int(1)and None
float(1.)and None
# EOF
$ ruff --isolated check up018_2.py --select UP018 --fix
Found 2 errors (2 fixed, 0 remaining).
$ cat up018_2.py
1and None
1.and None
$ python up018_2.py
up018_2.py:1: SyntaxWarning: invalid decimal literal
1and None
up018_2.py:2: SyntaxWarning: invalid decimal literal
1.and NoneRuntime behavior change:
$ cat >up018_3.py <<'# EOF'
bool(True)and()
# EOF
$ ruff --isolated check up018_3.py --select UP018 --fix
Found 1 error (1 fixed, 0 remaining).
$ cat up018_3.py
Trueand()
$ python up018_3.py
Traceback (most recent call last):
File "up018_3.py", line 1, in <module>
Trueand()
^^^^^^^
NameError: name 'Trueand' is not definedVersion
ruff 0.11.6 (fcd50a0 2025-04-17)
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationshelp wantedContributions especially welcomeContributions especially welcome