MCPcopy Create free account
hub / github.com/python/mypy / adjust_tuple

Function adjust_tuple

mypy/meet.py:767–772  ·  view source on GitHub ↗

Find out if `left` is a Tuple[A, ...], and adjust its length to `right`

(left: ProperType, r: ProperType)

Source from the content-addressed store, hash-verified

765
766
767def adjust_tuple(left: ProperType, r: ProperType) -> TupleType | None:
768 """Find out if `left` is a Tuple[A, ...], and adjust its length to `right`"""
769 if isinstance(left, Instance) and left.type.fullname == "builtins.tuple":
770 n = r.length() if isinstance(r, TupleType) else 1
771 return TupleType([left.args[0]] * n, left)
772 return None
773
774
775def is_tuple(typ: Type) -> bool:

Callers 1

are_tuples_overlappingFunction · 0.85

Calls 3

TupleTypeClass · 0.90
isinstanceFunction · 0.85
lengthMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…