-
Notifications
You must be signed in to change notification settings - Fork 132
Open
Labels
Description
Problem
PEP 604 allows the pipe symbol (|
) to annotate unions of types. In particular:
X | Y
Union[X,Y]
and
X | None
Optional[X]
However, type forwarding does not work with this new capability. I.e. "Xtype" | Y
doesn't work (though "Xtype | Y"
does actually work).
Currently our repo is inconsistent when it comes to union types.
Solution
We should settle on a best practice for such annotations, change all usages to adhere to the best practice, and add it to our style guide.
I propose that we disallow |
because of its incompatibility with forwarded types. But I'm open to discussion and don't have a strong opinion, except that we should have some convention.
Dependencies
None
Urgency
Very low