class documentation

The class of a heterogeneous tuple. The formal_type_parameters attribute stores the types of the individual tuple elements under their indices and the overall element type under "T". So for Tuple[str, int] formal_type_parameters is {0: str, 1: int, T: str or int}. Note that we can't store the individual types as a mixin.PythonConstant as we do for Tuple, since we can't evaluate type parameters during initialization.

Method __init__ Basic initializer for all BaseValues.
Method __repr__ Undocumented
Method add_slot Implementation of tuple.__add__.
Method compute_mro Compute the class precedence list (mro) according to C3.
Method get_formal_type_parameters Undocumented
Method get_special_attribute Fetch a special attribute (e.g., __get__, __iter__).
Method getitem_slot Implementation of tuple.__getitem__.
Method instantiate Create an instance of self.
Method register_instance Treating self as a class definition, register an instance of it.
Instance Variable slots Undocumented
Instance Variable tuple_length Undocumented
Method _instantiate_index Undocumented
Method _new_instance Returns a (possibly cached) instance of 'self'.
Instance Variable _instance Undocumented

Inherited from ParameterizedClass:

Method __contains__ Undocumented
Method __eq__ Undocumented
Method __hash__ Undocumented
Method __ne__ Undocumented
Method call Call this abstract value with the given arguments.
Method cls.setter Undocumented
Method get_formal_type_parameter Get the class's type for the type parameter.
Method get_inner_types Undocumented
Method get_own_abstract_methods Get the abstract methods defined by this class.
Method get_own_attributes Get the attributes defined by this class.
Method has_protocol_base Returns whether this class inherits directly from typing.Protocol.
Method official_name.setter Undocumented
Method replace Undocumented
Method set_class Undocumented
Method type_param_check Throw exception for invalid type parameters.
Method update_inner_type Undocumented
Instance Variable base_cls Undocumented
Instance Variable is_dynamic Undocumented
Instance Variable module Undocumented
Property cls Undocumented
Property formal_type_parameters Undocumented
Property members Undocumented
Property official_name Undocumented
Method _is_callable Undocumented
Method _load_formal_type_parameters Undocumented
Method _raw_formal_type_parameters Undocumented
Instance Variable _cls Undocumented
Instance Variable _formal_type_parameters Undocumented
Instance Variable _formal_type_parameters_loaded Undocumented
Instance Variable _hash Undocumented
Instance Variable _template Undocumented

Inherited from BaseValue (via ParameterizedClass):

Method argcount Returns the minimum number of arguments needed for a call.
Method default_mro Undocumented
Method get_default_fullhash Undocumented
Method get_default_type_key Gets a default type key. See get_type_key.
Method get_fullhash Undocumented
Method get_instance_type Get the type an instance of us would have.
Method get_instance_type_parameter Get a cfg.Variable of the instance's values for the type parameter.
Method get_own_new Get this value's __new__ method, if it isn't object.__new__.
Method get_type_key Build a key from the information used to perform type matching.
Method has_kwargs Return True if this is a function and has a **kwargs parameter.
Method has_varargs Return True if this is a function and has a *args parameter.
Method init_subclass Allow metaprogramming via __init_subclass__.
Method is_late_annotation Undocumented
Method module.setter Undocumented
Method property_get Bind this value to the given self or cls.
Method should_replace_self_annot Undocumented
Method to_annotation_container Undocumented
Method to_binding Undocumented
Method to_pytd_def Get a PyTD definition for this object.
Method to_type Get a PyTD type representing this object, as seen at a node.
Method to_variable Build a variable out of this abstract value.
Method unique_parameter_values Get unique parameter subtypes as bindings.
Method update_official_name Update the official name.
Class Variable formal Undocumented
Instance Variable final Undocumented
Instance Variable from_annotation Undocumented
Instance Variable is_concrete Undocumented
Instance Variable is_decorated Undocumented
Instance Variable mro Undocumented
Instance Variable name Undocumented
Property all_template_names Undocumented
Property full_name Undocumented
Property template Undocumented
Method _unique_parameters Get unique parameter subtypes as variables.
Instance Variable _all_template_names Undocumented
Instance Variable _module Undocumented
Instance Variable _official_name Undocumented

Inherited from ContextWeakrefMixin (via ParameterizedClass, BaseValue):

Class Variable __slots__ Undocumented
Instance Variable ctx_weakref Undocumented
Property ctx Undocumented

Inherited from Class (via ParameterizedClass, BaseValue, ContextWeakrefMixin):

Method __new__ Prevent direct instantiation.
Method bases Undocumented
Method call_init Undocumented
Method call_init_subclass Call init_subclass(cls) for all base classes.
Method call_metaclass_init Call the metaclass's __init__ method if it does anything interesting.
Method compute_attr_metadata Sets combined metadata based on inherited and own attrs.
Method compute_is_dynamic Undocumented
Method get_annotated_local Undocumented
Method has_dynamic_attributes Undocumented
Method init_mixin Mix-in equivalent of __init__.
Method is_test_class Undocumented
Method record_attr_ordering Records the order of attrs to write in the output pyi.
Class Variable overloads Undocumented
Instance Variable abstract_methods Undocumented
Instance Variable additional_init_methods Undocumented
Instance Variable metadata Undocumented
Instance Variable overrides_bool Undocumented
Instance Variable protocol_attributes Undocumented
Property all_formal_type_parameters Undocumented
Property annotations_dict Undocumented
Property is_abstract Undocumented
Property is_enum Undocumented
Property is_protocol Undocumented
Property is_typed_dict_class Undocumented
Method _call_method Undocumented
Method _call_new_and_init Call __new__ if it has been overridden on the given value.
Method _check_not_instantiable Report [not-instantiable] if the class cannot be instantiated.
Method _get_attrs_from_mro Traverse the MRO and collect base class attributes for metadata_key.
Method _get_class Undocumented
Method _get_inherited_metaclass Undocumented
Method _get_mro_attrs_for_attrs Traverse the MRO and collect base class attributes for metadata_key.
Method _has_explicit_abcmeta Undocumented
Method _has_implicit_abcmeta Whether the class should be considered implicitly abstract.
Method _init_abstract_methods Compute this class's abstract methods.
Method _init_overrides_bool Compute and cache whether the class sets its own boolean value.
Method _init_protocol_attributes Compute this class's protocol attributes.
Method _load_all_formal_type_parameters Load _all_formal_type_parameters.
Method _recompute_attrs_type_from_mro Traverse the MRO and apply Generic type params to class attributes.
Instance Variable _all_formal_type_parameters Undocumented
Instance Variable _all_formal_type_parameters_loaded Undocumented
Instance Variable _instance_cache Undocumented

Inherited from NestedAnnotation (via ParameterizedClass, BaseValue, ContextWeakrefMixin, Class):

Instance Variable processed Undocumented
Instance Variable _seen_for_formal Undocumented

Inherited from HasSlots (via ParameterizedClass, BaseValue, ContextWeakrefMixin, Class, NestedAnnotation):

Method call_pytd Call the (original) pytd version of a method we overwrote.
Method set_native_slot Add a new NativeFunction slot to this value.
Method set_slot Add a new slot to this value.
Instance Variable _slots Undocumented
Instance Variable _super Undocumented
def __init__(self, base_cls, formal_type_parameters, ctx, template=None): (source)

Basic initializer for all BaseValues.

def add_slot(self, node, other_var): (source)

Implementation of tuple.__add__.

def compute_mro(self): (source)

Compute the class precedence list (mro) according to C3.

def get_formal_type_parameters(self): (source)
def get_special_attribute(self, node, name, valself): (source)

Fetch a special attribute (e.g., __get__, __iter__).

def getitem_slot(self, node, index_var): (source)

Implementation of tuple.__getitem__.

def instantiate(self, node, container=None): (source)

Create an instance of self. Note that this method does not call __init__, so the instance may be incomplete. If you need a complete instance, use self.ctx.vm.init_class instead. Args: node: The current node. container: Optionally, the value that contains self. (See TypeParameter.) Returns: The instance.

def register_instance(self, instance): (source)

Treating self as a class definition, register an instance of it. This is used for keeping merging call records on instances when generating the formal definition of a class. See InterpreterClass and TupleClass. Args: instance: An instance of this class (as a BaseValue)

tuple_length = (source)

Undocumented

def _instantiate_index(self, node, index): (source)

Undocumented

def _new_instance(self, container, node, args): (source)

Returns a (possibly cached) instance of 'self'.