File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -5079,10 +5079,19 @@ def fast_container_type(
5079
5079
self .resolved_type [e ] = NoneType ()
5080
5080
return None
5081
5081
values .append (self .accept (item ))
5082
- vt = join .join_type_list (values )
5083
- if not allow_fast_container_literal (vt ):
5084
- self .resolved_type [e ] = NoneType ()
5085
- return None
5082
+
5083
+ values = [v for i , v in enumerate (values ) if v not in values [:i ]]
5084
+ if len (values ) == 1 :
5085
+ # If only one non-duplicate item remains, there's no need running whole
5086
+ # inference cycle over it. This helps in pathological cases where items
5087
+ # are complex overloads.
5088
+ # https://github.com/python/mypy/issues/14718
5089
+ vt = values [0 ]
5090
+ else :
5091
+ vt = join .join_type_list (values )
5092
+ if not allow_fast_container_literal (vt ):
5093
+ self .resolved_type [e ] = NoneType ()
5094
+ return None
5086
5095
ct = self .chk .named_generic_type (container_fullname , [vt ])
5087
5096
self .resolved_type [e ] = ct
5088
5097
return ct
You can’t perform that action at this time.
0 commit comments