33from mypy .messages import callable_name
44from mypy .plugin import MethodSigContext
55from mypy .subtypes import is_subtype
6- from mypy .typeops import get_type_vars
6+ from mypy .typeops import get_type_vars , make_simplified_union
77from mypy .types import CallableType , Instance , ProperType
88from 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
1610from typing_extensions import Final , final
1711
1812from 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 (sorted (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,9 +92,9 @@ 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 ( sorted (
95+ self ._signature .arg_types [0 ] = make_simplified_union (
10596 list (filter (None , [self ._instance_type , supports_type ])),
106- ))
97+ )
10798 return self ._signature
10899
109100
0 commit comments