-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationshelp wantedContributions especially welcomeContributions especially welcome
Description
The fixes for redundant-none-literal (PYI061) and never-union (RUF020) in Ruff 0.8.0 can generate None | None, which raises an error at runtime.
PYI061 example:
$ cat pyi061.py
from typing import Literal
x: Literal[None] | None
$ ruff check --isolated --preview --select PYI061 pyi061.py --fix
Found 1 error (1 fixed, 0 remaining).
$ cat pyi061.py
from typing import Literal
x: None | None
$ python pyi061.py
Traceback (most recent call last):
File "pyi061.py", line 2, in <module>
x: None | None
~~~~~^~~~~~
TypeError: unsupported operand type(s) for |: 'NoneType' and 'NoneType'RUF020 example:
$ cat ruf020.py
from typing import Never
x: None | Never | None
$ ruff check --isolated --select RUF020 ruf020.py --fix
Found 1 error (1 fixed, 0 remaining).
$ cat ruf020.py
from typing import Never
x: None | None
$ python ruf020.py
Traceback (most recent call last):
File "ruf020.py", line 2, in <module>
x: None | None
~~~~~^~~~~~
TypeError: unsupported operand type(s) for |: 'NoneType' and 'NoneType'Reactions are currently unavailable
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