Skip to content

Commit b8cff96

Browse files
committed
Do not cache another bug
1 parent e328fdb commit b8cff96

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

mypy/typeops.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,12 @@ def type_object_type(info: TypeInfo, named_type: Callable[[str], Instance]) -> P
177177
init_index = info.mro.index(init_method.node.info)
178178
new_index = info.mro.index(new_method.node.info)
179179

180-
fallback = info.metaclass_type or named_type("builtins.type")
180+
if checker_state.type_checker:
181+
builtins_type = checker_state.type_checker.named_type("builtins.type")
182+
else:
183+
builtins_type = named_type("builtins.type")
184+
185+
fallback = info.metaclass_type or builtins_type
181186
if init_index < new_index:
182187
method: FuncBase | Decorator = init_method.node
183188
is_new = False
@@ -1270,6 +1275,8 @@ def get_protocol_member(
12701275
if member == "__call__" and class_obj:
12711276
# Special case: class objects always have __call__ that is just the constructor.
12721277

1278+
# TODO: this is wrong, it creates callables that are not recognized as type objects.
1279+
# Long-term, we should probably get rid of this callback argument altogether.
12731280
def named_type(fullname: str) -> Instance:
12741281
return Instance(left.type.mro[-1], [])
12751282

0 commit comments

Comments
 (0)