ruff
28ab61d8 - [`pyupgrade`] Avoid PEP-604 unions with `typing.NamedTuple` (`UP007`, `UP045`) (#18682)

Commit
76 days ago
[`pyupgrade`] Avoid PEP-604 unions with `typing.NamedTuple` (`UP007`, `UP045`) (#18682) <!-- Thank you for contributing to Ruff/ty! To help us out with reviewing, please consider the following: - Does this pull request include a summary of the change? (See below.) - Does this pull request include a descriptive title? (Please prefix with `[ty]` for ty pull requests.) - Does this pull request include references to any relevant issues? --> ## Summary Make `UP045` ignore `Optional[NamedTuple]` as `NamedTuple` is a function (not a proper type). Rewriting it to `NamedTuple | None` breaks at runtime. While type checkers currently accept `NamedTuple` as a type, they arguably shouldn't. Therefore, we outright ignore it and don't touch or lint on it. For a more detailed discussion, see the linked issue. ## Test Plan Added examples to the existing tests. ## Related Issues Fixes: https://github.com/astral-sh/ruff/issues/18619
Author
Parents
Loading