-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Open
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 non-pep604-annotation-optional (UP045) can produce None | None, the persistently inconvenient exception to PEP 604.
$ cat >up045.py <<'# EOF'
from typing import Optional
foo: Optional[None] = None
# EOF
$ ruff --isolated check up045.py --select UP045 --preview --target-version py310 --fix
Found 1 error (1 fixed, 0 remaining).
$ cat up045.py
from typing import Optional
foo: None | None = None
$ python up045.py 2>&1 | tail -n 1
TypeError: unsupported operand type(s) for |: 'NoneType' and 'NoneType'Version
ruff 0.11.13 (5faf72a 2025-06-05)
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