We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 78e8785 commit 0bacb41Copy full SHA for 0bacb41
Lib/typing.py
@@ -787,18 +787,9 @@ def Union(self, parameters):
787
def _union_from_types(left, right):
788
"""Helper function to create union types avoiding recursion."""
789
try:
790
- if hasattr(left, '__or__') and not isinstance(left, _GenericAlias):
791
- return left | right
792
- elif hasattr(right, '__ror__') and not isinstance(right, _GenericAlias):
793
- return right.__ror__(left)
794
- else:
795
- if hasattr(left, '__origin__'):
796
- left = left.__origin__
797
- if hasattr(right, '__origin__'):
798
- right = right.__origin__
799
+ return left | right
800
except (TypeError, AttributeError):
801
- return f"Union[{left}, {right}]"
+ return Union[left, right]
802
803
804
@_SpecialForm
0 commit comments