@@ -1329,15 +1329,18 @@ def type_object_type(info: TypeInfo, named_type: Callable[[str], Instance]) -> P
13291329 """
13301330
13311331 # We take the type from whichever of __init__ and __new__ is first
1332- # in the MRO, preferring __init__ if there is a tie.
1332+ # in the MRO, preferring __new__ if there is a tie.
13331333 init_method = info .get ("__init__" )
13341334 new_method = info .get ("__new__" )
13351335 if not init_method or not is_valid_constructor (init_method .node ):
13361336 # Must be an invalid class definition.
13371337 return AnyType (TypeOfAny .from_error )
13381338 # There *should* always be a __new__ method except the test stubs
1339- # lack it, so just copy init_method in that situation
1340- new_method = new_method or init_method
1339+ # lack it, so just copy builtin's init in that situation
1340+ if new_method is None :
1341+ new_method = named_type ("builtins.object" ).type .get ("__init__" )
1342+ if not new_method :
1343+ return AnyType (TypeOfAny .from_error )
13411344 if not is_valid_constructor (new_method .node ):
13421345 # Must be an invalid class definition.
13431346 return AnyType (TypeOfAny .from_error )
@@ -1371,12 +1374,13 @@ def type_object_type(info: TypeInfo, named_type: Callable[[str], Instance]) -> P
13711374 fallback = named_type ("builtins.function" ),
13721375 )
13731376 return class_callable (sig , info , fallback , None , is_new = False )
1374-
1375- # Otherwise prefer __init__ in a tie. It isn't clear that this
1376- # is the right thing, but __new__ caused problems with
1377- # typeshed (#5647).
1378- method = init_method .node
1379- is_new = False
1377+ if init_method .node .info .fullname == "builtins.dict" :
1378+ # dict.__new__ in typeshed is pretty unhelpful
1379+ method = init_method .node
1380+ is_new = False
1381+ else :
1382+ method = new_method .node
1383+ is_new = True
13801384 # Construct callable type based on signature of __init__. Adjust
13811385 # return type and insert type arguments.
13821386 if isinstance (method , FuncBase ):
0 commit comments