Skip to content

Commit c2c55d6

Browse files
committed
New union
1 parent bc7f06a commit c2c55d6

File tree

1 file changed

+4
-13
lines changed

1 file changed

+4
-13
lines changed

classes/contrib/mypy/typeops/call_signatures.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,10 @@
33
from mypy.messages import callable_name
44
from mypy.plugin import MethodSigContext
55
from mypy.subtypes import is_subtype
6-
from mypy.typeops import get_type_vars
6+
from mypy.typeops import get_type_vars, make_simplified_union
77
from mypy.types import CallableType, Instance, ProperType
88
from mypy.types import Type as MypyType
9-
from mypy.types import (
10-
TypeVarDef,
11-
TypeVarId,
12-
TypeVarType,
13-
UnionType,
14-
union_items,
15-
)
9+
from mypy.types import TypeVarDef, TypeVarId, TypeVarType, union_items
1610
from typing_extensions import Final, final
1711

1812
from classes.contrib.mypy.typeops import type_loader
@@ -75,10 +69,7 @@ def _infer_type_var(
7569
self._ctx,
7670
))
7771

78-
# We use `make_union` instead of `make_simplified_union`
79-
# to show all instance items in the output,
80-
# for example `Union[int, float]` won't be converted into `float`.
81-
instance_type = UnionType.make_union(instance_types)
72+
instance_type = make_simplified_union(instance_types)
8273
if not is_subtype(passed_type, instance_type):
8374
# Let's explain: what happens here?
8475
# We need to enforce
@@ -101,7 +92,7 @@ def _infer_regular(self, first_arg: MypyType) -> CallableType:
10192
self._ctx,
10293
should_replace_typevars=True,
10394
)
104-
self._signature.arg_types[0] = UnionType.make_union(
95+
self._signature.arg_types[0] = make_simplified_union(
10596
list(filter(None, [self._instance_type, supports_type])),
10697
)
10798
return self._signature

0 commit comments

Comments
 (0)