class documentation

An abstract wrapper for PyTD class objects. These are the abstract values for class objects that are described in PyTD. Attributes: cls: A pytd.Class mro: Method resolution order. An iterable of BaseValue.

Class Method make Undocumented
Method __contains__ Undocumented
Method __init__ Initialize a SimpleValue.
Method __repr__ Undocumented
Method bases Undocumented
Method convert_as_instance_attribute Convert `name` as an instance attribute.
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 instantiate Create an instance of self.
Method load_lazy_attribute Load the named attribute into self.members.
Instance Variable final Undocumented
Instance Variable final_members Undocumented
Instance Variable has_explicit_init Undocumented
Instance Variable is_dynamic Undocumented
Instance Variable pytd_cls Undocumented
Instance Variable slots Undocumented
Method _convert_member Convert a member as a variable. For lazy lookup.
Method _init_attr_metadata_from_pytd Initialise metadata[key] with a list of Attributes.
Method _new_instance Returns a (possibly cached) instance of 'self'.
Method _populate_decorator_metadata Fill in class attribute metadata for decorators like @dataclass.
Method _recompute_init_from_metadata Undocumented

Inherited from SimpleValue:

Method argcount Returns the minimum number of arguments needed for a call.
Method call Call this abstract value with the given arguments.
Method cls.setter Undocumented
Method get_fullhash Undocumented
Method get_instance_type_parameter Get a cfg.Variable of the instance's values for the type parameter.
Method get_type_key Build a key from the information used to perform type matching.
Method has_instance_type_parameter Check if the key is in `instance_type_parameters`.
Method maybe_missing_members.setter Undocumented
Method merge_instance_type_parameter Set the value of a type parameter.
Method set_class Set the __class__ of an instance, for code that does "x.__class__ = y.
Method update_caches Undocumented
Instance Variable members Undocumented
Property cls Undocumented
Property instance_type_parameters Undocumented
Property maybe_missing_members Undocumented
Method _call_helper Undocumented
Method _get_changestamps Undocumented
Method _get_class Undocumented
Method _unique_parameters Get unique parameter subtypes as variables.
Instance Variable _cached_changestamps Undocumented
Instance Variable _cls Undocumented
Instance Variable _fullhash Undocumented
Instance Variable _instance_type_parameters Undocumented
Instance Variable _maybe_missing_members Undocumented
Instance Variable _type_key Undocumented

Inherited from BaseValue (via SimpleValue):

Method compute_mro Undocumented
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_formal_type_parameter Get the class's type for the type parameter.
Method get_instance_type Get the type an instance of us would have.
Method get_own_new Get this value's __new__ method, if it isn't object.__new__.
Method get_special_attribute Fetch a special attribute (e.g., __get__, __iter__).
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 official_name.setter Undocumented
Method property_get Bind this value to the given self or cls.
Method register_instance Treating self as a class definition, register an instance of it.
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 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 module Undocumented
Property official_name Undocumented
Property template Undocumented
Instance Variable _all_template_names Undocumented
Instance Variable _instance Undocumented
Instance Variable _module Undocumented
Instance Variable _official_name Undocumented
Instance Variable _template Undocumented

Inherited from ContextWeakrefMixin (via SimpleValue, BaseValue):

Class Variable __slots__ Undocumented
Instance Variable ctx_weakref Undocumented
Property ctx Undocumented

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

Method __new__ Prevent direct instantiation.
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_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 LazyMembers (via SimpleValue, BaseValue, ContextWeakrefMixin, Class):

Instance Variable _member_map Undocumented
@classmethod
def make(cls, name, pytd_cls, ctx): (source)

Undocumented

def __contains__(self, name): (source)

Undocumented

def bases(self): (source)
def convert_as_instance_attribute(self, name, instance): (source)

Convert `name` as an instance attribute. This method is used by attribute.py to lazily load attributes on instances of this PyTDClass. Calling this method directly should be avoided. Doing so will create multiple copies of the same attribute, leading to subtle bugs. Args: name: The attribute name. instance: An instance of this PyTDClass. Returns: The converted attribute.

def get_own_abstract_methods(self): (source)

Get the abstract methods defined by this class.

def get_own_attributes(self): (source)

Get the attributes defined by this class.

def has_protocol_base(self): (source)

Returns whether this class inherits directly from typing.Protocol. Subclasses that may inherit from Protocol should override this method.

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 load_lazy_attribute(self, name, subst=None, store=True): (source)

Load the named attribute into self.members.

final_members: dict = (source)

Undocumented

has_explicit_init = (source)

Undocumented

is_dynamic = (source)

Undocumented

pytd_cls = (source)

Undocumented

def _convert_member(self, name, member, subst=None): (source)

Convert a member as a variable. For lazy lookup.

def _init_attr_metadata_from_pytd(self, decorator): (source)

Initialise metadata[key] with a list of Attributes.

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

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

def _populate_decorator_metadata(self): (source)

Fill in class attribute metadata for decorators like @dataclass.

def _recompute_init_from_metadata(self, key): (source)

Undocumented