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

Class TypeVarTupleExpr

mypy/nodes.py:3331–3403  ·  view source on GitHub ↗

Type variable tuple expression TypeVarTuple(...).

Source from the content-addressed store, hash-verified

3329
3330
3331class TypeVarTupleExpr(TypeVarLikeExpr):
3332 """Type variable tuple expression TypeVarTuple(...)."""
3333
3334 __slots__ = "tuple_fallback"
3335
3336 tuple_fallback: mypy.types.Instance
3337
3338 __match_args__ = ("name", "upper_bound", "default")
3339
3340 def __init__(
3341 self,
3342 name: str,
3343 fullname: str,
3344 upper_bound: mypy.types.Type,
3345 tuple_fallback: mypy.types.Instance,
3346 default: mypy.types.Type,
3347 variance: int = INVARIANT,
3348 is_new_style: bool = False,
3349 line: int = -1,
3350 ) -> None:
3351 super().__init__(name, fullname, upper_bound, default, variance, is_new_style, line=line)
3352 self.tuple_fallback = tuple_fallback
3353
3354 def accept(self, visitor: ExpressionVisitor[T]) -> T:
3355 return visitor.visit_type_var_tuple_expr(self)
3356
3357 def serialize(self) -> JsonDict:
3358 return {
3359 ".class": "TypeVarTupleExpr",
3360 "name": self._name,
3361 "fullname": self._fullname,
3362 "upper_bound": self.upper_bound.serialize(),
3363 "tuple_fallback": self.tuple_fallback.serialize(),
3364 "default": self.default.serialize(),
3365 "variance": self.variance,
3366 }
3367
3368 @classmethod
3369 def deserialize(cls, data: JsonDict) -> TypeVarTupleExpr:
3370 assert data[".class"] == "TypeVarTupleExpr"
3371 return TypeVarTupleExpr(
3372 data["name"],
3373 data["fullname"],
3374 mypy.types.deserialize_type(data["upper_bound"]),
3375 mypy.types.Instance.deserialize(data["tuple_fallback"]),
3376 mypy.types.deserialize_type(data["default"]),
3377 data["variance"],
3378 )
3379
3380 def write(self, data: WriteBuffer) -> None:
3381 write_tag(data, TYPE_VAR_TUPLE_EXPR)
3382 self.tuple_fallback.write(data)
3383 write_str(data, self._name)
3384 write_str(data, self._fullname)
3385 self.upper_bound.write(data)
3386 self.default.write(data)
3387 write_int(data, self.variance)
3388 write_tag(data, END_TAG)

Callers 5

analyze_type_paramMethod · 0.90
deserializeMethod · 0.85
readMethod · 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…