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

Class TypeVarType

mypy/types.py:641–755  ·  view source on GitHub ↗

Type that refers to a type variable.

Source from the content-addressed store, hash-verified

639
640
641class TypeVarType(TypeVarLikeType):
642 """Type that refers to a type variable."""
643
644 __slots__ = ("values", "variance")
645
646 values: list[Type] # Value restriction, empty list if no restriction
647 variance: int
648
649 def __init__(
650 self,
651 name: str,
652 fullname: str,
653 id: TypeVarId,
654 values: list[Type],
655 upper_bound: Type,
656 default: Type,
657 variance: int = INVARIANT,
658 line: int = -1,
659 column: int = -1,
660 ) -> None:
661 super().__init__(name, fullname, id, upper_bound, default, line, column)
662 assert values is not None, "No restrictions must be represented by empty list"
663 self.values = values
664 self.variance = variance
665
666 def copy_modified(
667 self,
668 *,
669 values: Bogus[list[Type]] = _dummy,
670 upper_bound: Bogus[Type] = _dummy,
671 default: Bogus[Type] = _dummy,
672 id: Bogus[TypeVarId] = _dummy,
673 line: int = _dummy_int,
674 column: int = _dummy_int,
675 **kwargs: Any,
676 ) -> TypeVarType:
677 return TypeVarType(
678 name=self.name,
679 fullname=self.fullname,
680 id=self.id if id is _dummy else id,
681 values=self.values if values is _dummy else values,
682 upper_bound=self.upper_bound if upper_bound is _dummy else upper_bound,
683 default=self.default if default is _dummy else default,
684 variance=self.variance,
685 line=self.line if line == _dummy_int else line,
686 column=self.column if column == _dummy_int else column,
687 )
688
689 def accept(self, visitor: TypeVisitor[T]) -> T:
690 return visitor.visit_type_var(self)
691
692 def __hash__(self) -> int:
693 return hash((self.id, self.upper_bound, tuple(self.values)))
694
695 def __eq__(self, other: object) -> bool:
696 if not isinstance(other, TypeVarType):
697 return NotImplemented
698 return (

Callers 15

check_lst_exprMethod · 0.90
visit_dict_exprMethod · 0.90
setup_self_typeMethod · 0.90
anal_var_defMethod · 0.90
bind_newMethod · 0.90
make_type_varMethod · 0.90
make_type_infoMethod · 0.90

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…