Skip to content

Commit 2f66bcc

Browse files
committed
Fix mypyc breakage caused by mypy multiple inheritance bug
Bug #3603 strikes again. We've got this workaround in another place or two.
1 parent 8db9ce5 commit 2f66bcc

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

mypy/checkmember.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Type checking of attribute access"""
22

3-
from typing import cast, Callable, List, Optional, TypeVar
3+
from typing import cast, Callable, List, Optional, TypeVar, Any
44

55
from mypy.types import (
66
Type, Instance, AnyType, TupleType, TypedDictType, CallableType, FunctionLike, TypeVarDef,
@@ -624,10 +624,12 @@ def analyze_class_attribute_access(itype: Instance,
624624
return mx.chk.handle_partial_var_type(t, mx.is_lvalue, symnode, mx.context)
625625

626626
# Find the class where method/variable was defined.
627-
if isinstance(node.node, Decorator):
628-
super_info = node.node.var.info # type: Optional[TypeInfo]
629-
elif isinstance(node.node, (Var, FuncBase)):
630-
super_info = node.node.info
627+
# mypyc hack to workaround mypy misunderstanding multiple inheritance (#3603)
628+
node_node = node.node # type: Any
629+
if isinstance(node_node, Decorator):
630+
super_info = node_node.var.info # type: Optional[TypeInfo]
631+
elif isinstance(node_node, (Var, FuncBase)):
632+
super_info = node_node.info
631633
else:
632634
super_info = None
633635

0 commit comments

Comments
 (0)