Open
Description
Summary
Rule UP007 which replaces Union
type hints with |
and Optional[foo]
with foo | None
crashes on all versions of Python including the latest ones under the very specific circumstance of replacing Optional[typing.NamedTuple]
with typing.NamedTuple | None
.
The error is:
TypeError: unsupported operand type(s) for |: `function` and `NoneType`
I tested on Python 3.11, 3.13 saw identical behavior in all cases. It does work fine on 3.14 due to deferred type evaluation.
Version
ruff 0.11.13 as installed from uv