Skip to content

Commit

Permalink
Try to infer any variances that can be inferred
Browse files Browse the repository at this point in the history
Also avoid inferring variances repeatedly.
  • Loading branch information
JukkaL committed May 16, 2024
1 parent 369a4af commit dba87a8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions mypy/subtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2049,8 +2049,9 @@ def infer_class_variances(info: TypeInfo) -> bool:
if not info.defn.type_args:
return True
tvs = info.defn.type_vars
success = True
for i, tv in enumerate(tvs):
if isinstance(tv, TypeVarType):
if isinstance(tv, TypeVarType) and tv.variance == VARIANCE_NOT_READY:
if not infer_variance(info, i):
return False
return True
success = False
return success

0 comments on commit dba87a8

Please sign in to comment.