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(
50795079 self .resolved_type [e ] = NoneType ()
50805080 return None
50815081 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
50865095 ct = self .chk .named_generic_type (container_fullname , [vt ])
50875096 self .resolved_type [e ] = ct
50885097 return ct
You can’t perform that action at this time.
0 commit comments