MonkeyType icon indicating copy to clipboard operation
MonkeyType copied to clipboard

Support PEP 604 Union syntax (Union[a, b] → a | b)

Open AllanLeanderRostockHansen opened this issue 2 years ago • 2 comments

PEP 604 introduces a new Union syntax in Python 3.10+. It would be nice if Monkeytype could leverage that, and perhaps have a flag to use a union with None rather than the Optional type.

# Old syntax
def foo(a: Optional[Union[float, int]]) -> Optional[float]:
    ...

# New syntax
def foo(a: float | int | None) -> float | None:
    ...

Yes, this would be awesome!

EwoutH avatar Mar 20 '23 09:03 EwoutH

Agreed, this would be a nice improvement. MonkeyType is currently in maintenance mode; I'd be happy to review a contributed PR for this, but it's not likely to happen otherwise.

carljm avatar Mar 20 '23 13:03 carljm