Replace typing.Union[X, Y] with X | Y
ProprietaryPEP 604 introduced the | operator for union types in Python 3.10. Replace Union[X, Y, ...] with the more concise X | Y | ... syntax. Applies inside if TYPE_CHECKING: blocks as well; X | Y is valid at runtime from Python 3.10 on, so no from __future__ import annotations is needed. A subscript holding a string forward reference or a comment is left alone.
org. openrewrite. python. migrate. ReplaceTypingUnionWithPipemod run . --recipe= org. openrewrite. python. migrate. ReplaceTypingUnionWithPipeInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.