Skip to content

Commit 2c29487

Browse files
committed
Better solution for is_subtype check
1 parent c8268d5 commit 2c29487

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

mypy/subtypes.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -290,9 +290,6 @@ def _is_subtype(
290290
# ErasedType as we do for non-proper subtyping.
291291
return True
292292

293-
if not proper_subtype and isinstance(right, TypeVarType) and right.has_default():
294-
return left.accept(SubtypeVisitor(right.default, subtype_context, proper_subtype))
295-
296293
if isinstance(right, UnionType) and not isinstance(left, UnionType):
297294
# Normally, when 'left' is not itself a union, the only way
298295
# 'left' can be a subtype of the union 'right' is if it is a
@@ -621,8 +618,9 @@ def check_mixed(
621618
if call:
622619
return self._is_subtype(call, right)
623620
return False
624-
else:
625-
return False
621+
if isinstance(right, TypeVarType) and right.has_default():
622+
return self._is_subtype(left, right.default)
623+
return False
626624

627625
def visit_type_var(self, left: TypeVarType) -> bool:
628626
right = self.right

0 commit comments

Comments
 (0)