Find out if this constraint represent a linear relationship, return target id if yes.
(c: Constraint)
| 387 | |
| 388 | |
| 389 | def 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 | |
| 406 | def transitive_closure( |
no test coverage detected
searching dependent graphs…