You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As far as I can tell, this happens because typing.Union is implemented using typing._SpecialForm, and _SpecialForm is implemented using __getitem__ to support parameterisation like Union[int]. Unfortunately, because _SpecialForm doesn't implement __iter__, __getitem__ is also used for iteration - meaning that when trying to iterate, we effectively do Union[0], Union[1], etc.
The text was updated successfully, but these errors were encountered:
If you accidentally iterate over a
Union
, you get a hang:It looks like it's an infinite loop:
As far as I can tell, this happens because
typing.Union
is implemented usingtyping._SpecialForm
, and_SpecialForm
is implemented using__getitem__
to support parameterisation likeUnion[int]
. Unfortunately, because_SpecialForm
doesn't implement__iter__
,__getitem__
is also used for iteration - meaning that when trying to iterate, we effectively doUnion[0]
,Union[1]
, etc.The text was updated successfully, but these errors were encountered: