Skip to content

Commit c6bd0c6

Browse files
authored
Tentative fix for crash in --quick mode (#3233)
Hopefully fixes #3214.
1 parent 0a9f88d commit c6bd0c6

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

mypy/subtypes.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,14 @@ def visit_instance(self, left: Instance) -> bool:
135135
if isinstance(right, TupleType) and right.fallback.type.is_enum:
136136
return is_subtype(left, right.fallback)
137137
if isinstance(right, Instance):
138-
for base in left.type.mro:
139-
if base._promote and is_subtype(
140-
base._promote, self.right, self.check_type_parameter,
141-
ignore_pos_arg_names=self.ignore_pos_arg_names):
142-
return True
138+
# NOTO: left.type.mro may be None in quick mode if there
139+
# was an error somewhere.
140+
if left.type.mro is not None:
141+
for base in left.type.mro:
142+
if base._promote and is_subtype(
143+
base._promote, self.right, self.check_type_parameter,
144+
ignore_pos_arg_names=self.ignore_pos_arg_names):
145+
return True
143146
rname = right.type.fullname()
144147
if not left.type.has_base(rname) and rname != 'builtins.object':
145148
return False

0 commit comments

Comments
 (0)