MCPcopy Index your code
hub / github.com/python/mypy / check_linear

Function check_linear

mypy/solve.py:518–528  ·  view source on GitHub ↗

Check there are only linear constraints between type variables in SCC. Linear are constraints like T <: S (while T <: F[S] are non-linear).

(scc: set[TypeVarId], lowers: Bounds, uppers: Bounds)

Source from the content-addressed store, hash-verified

516
517
518def check_linear(scc: set[TypeVarId], lowers: Bounds, uppers: Bounds) -> bool:
519 """Check there are only linear constraints between type variables in SCC.
520
521 Linear are constraints like T <: S (while T <: F[S] are non-linear).
522 """
523 for tv in scc:
524 if any(get_vars(lt, list(scc)) for lt in lowers[tv]):
525 return False
526 if any(get_vars(ut, list(scc)) for ut in uppers[tv]):
527 return False
528 return True
529
530
531def skip_reverse_union_constraints(cs: list[Constraint]) -> list[Constraint]:

Callers 1

solve_with_dependentFunction · 0.85

Calls 3

anyFunction · 0.85
get_varsFunction · 0.85
listClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…