File tree Expand file tree Collapse file tree 2 files changed +5
-0
lines changed
Expand file tree Collapse file tree 2 files changed +5
-0
lines changed Original file line number Diff line number Diff line change @@ -328,6 +328,8 @@ def _infer_constraints(
328328 template = mypy .typeops .make_simplified_union (template .items , keep_erased = True )
329329 if isinstance (actual , UnionType ):
330330 actual = mypy .typeops .make_simplified_union (actual .items , keep_erased = True )
331+ if isinstance (actual , TypeVarType ) and actual .has_default ():
332+ actual = get_proper_type (actual .default )
331333
332334 # Ignore Any types from the type suggestion engine to avoid them
333335 # causing us to infer Any in situations where a better job could
Original file line number Diff line number Diff line change @@ -303,6 +303,9 @@ def _is_subtype(
303303 # ErasedType as we do for non-proper subtyping.
304304 return True
305305
306+ if not proper_subtype and isinstance (right , TypeVarType ) and right .has_default ():
307+ return left .accept (SubtypeVisitor (right .default , subtype_context , proper_subtype ))
308+
306309 if isinstance (right , UnionType ) and not isinstance (left , UnionType ):
307310 # Normally, when 'left' is not itself a union, the only way
308311 # 'left' can be a subtype of the union 'right' is if it is a
You can’t perform that action at this time.
0 commit comments