Skip to content

Commit ad66ae1

Browse files
committed
reorder union check correctly for future contents checking
1 parent df7e9ad commit ad66ae1

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

mypy/stubtest.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,11 +1043,14 @@ def verify_typealias(
10431043
)
10441044
return
10451045
if isinstance(stub_target, mypy.types.UnionType):
1046-
# could check Union contents here...
10471046
if sys.version_info >= (3, 10) and isinstance(runtime, types.UnionType):
10481047
return
1049-
if runtime_type is not Union:
1048+
# complain if runtime is not a Union or UnionType
1049+
if runtime_type is not Union and (
1050+
not (sys.version_info >= (3, 10) and isinstance(runtime, types.UnionType))
1051+
):
10501052
yield Error(object_path, "is not a Union", stub, runtime, stub_desc=str(stub_target))
1053+
# could check Union contents here...
10511054
return
10521055
if isinstance(stub_target, mypy.types.TupleType):
10531056
if tuple not in getattr(runtime_type, "__mro__", ()):

0 commit comments

Comments
 (0)