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

Function find_linear

mypy/solve.py:389–403  ·  view source on GitHub ↗

Find out if this constraint represent a linear relationship, return target id if yes.

(c: Constraint)

Source from the content-addressed store, hash-verified

387
388
389def find_linear(c: Constraint) -> tuple[bool, TypeVarId | None]:
390 """Find out if this constraint represent a linear relationship, return target id if yes."""
391 if isinstance(c.origin_type_var, TypeVarType):
392 if isinstance(c.target, TypeVarType):
393 return True, c.target.id
394 if isinstance(c.origin_type_var, ParamSpecType):
395 if isinstance(c.target, ParamSpecType) and not c.target.prefix.arg_types:
396 return True, c.target.id
397 if isinstance(c.origin_type_var, TypeVarTupleType):
398 target = get_proper_type(c.target)
399 if isinstance(target, TupleType) and len(target.items) == 1:
400 item = target.items[0]
401 if isinstance(item, UnpackType) and isinstance(item.type, TypeVarTupleType):
402 return True, item.type.id
403 return False, None
404
405
406def transitive_closure(

Callers 1

transitive_closureFunction · 0.85

Calls 3

get_proper_typeFunction · 0.90
isinstanceFunction · 0.85
lenFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…