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

Class TypeVarTupleType

mypy/types.py:915–1027  ·  view source on GitHub ↗

Type that refers to a TypeVarTuple. See PEP646 for more information.

Source from the content-addressed store, hash-verified

913
914
915class TypeVarTupleType(TypeVarLikeType):
916 """Type that refers to a TypeVarTuple.
917
918 See PEP646 for more information.
919 """
920
921 __slots__ = ("tuple_fallback", "min_len")
922
923 def __init__(
924 self,
925 name: str,
926 fullname: str,
927 id: TypeVarId,
928 upper_bound: Type,
929 tuple_fallback: Instance,
930 default: Type,
931 *,
932 line: int = -1,
933 column: int = -1,
934 min_len: int = 0,
935 ) -> None:
936 super().__init__(name, fullname, id, upper_bound, default, line=line, column=column)
937 self.tuple_fallback = tuple_fallback
938 # This value is not settable by a user. It is an internal-only thing to support
939 # len()-narrowing of variadic tuples.
940 self.min_len = min_len
941
942 def serialize(self) -> JsonDict:
943 assert not self.id.is_meta_var()
944 return {
945 ".class": "TypeVarTupleType",
946 "name": self.name,
947 "fullname": self.fullname,
948 "id": self.id.raw_id,
949 "namespace": self.id.namespace,
950 "upper_bound": self.upper_bound.serialize(),
951 "tuple_fallback": self.tuple_fallback.serialize(),
952 "default": self.default.serialize(),
953 "min_len": self.min_len,
954 }
955
956 @classmethod
957 def deserialize(cls, data: JsonDict) -> TypeVarTupleType:
958 assert data[".class"] == "TypeVarTupleType"
959 return TypeVarTupleType(
960 data["name"],
961 data["fullname"],
962 TypeVarId(data["id"], namespace=data["namespace"]),
963 deserialize_type(data["upper_bound"]),
964 Instance.deserialize(data["tuple_fallback"]),
965 deserialize_type(data["default"]),
966 min_len=data["min_len"],
967 )
968
969 def write(self, data: WriteBuffer) -> None:
970 write_tag(data, TYPE_VAR_TUPLE_TYPE)
971 self.tuple_fallback.write(data)
972 write_str(data, self.name)

Callers 10

fill_typevarsFunction · 0.90
bind_newMethod · 0.90
visit_type_var_tupleMethod · 0.90
make_type_var_tupleMethod · 0.90
make_type_infoMethod · 0.90
deserializeMethod · 0.85
readMethod · 0.85
copy_modifiedMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…