class documentation

A single abstract value such as a type or function signature. This is the base class of the things that appear in Variables. It represents an atomic object that the abstract interpreter works over just as variables represent sets of parallel options. Conceptually abstract values represent sets of possible concrete values in compact form. For instance, an abstract value with .__class__ = int represents all ints.

Method __init__ Basic initializer for all BaseValues.
Method __repr__ Undocumented
Method argcount Returns the minimum number of arguments needed for a call.
Method call Call this abstract value with the given arguments.
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_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_special_attribute Fetch a special attribute (e.g., __get__, __iter__).
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 instantiate Create an instance of self.
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 cls 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
Instance Variable slots Undocumented
Property all_template_names Undocumented
Property full_name Undocumented
Property module Undocumented
Property official_name Undocumented
Property template Undocumented
Method _unique_parameters Get unique parameter subtypes as variables.
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:

Class Variable __slots__ Undocumented
Instance Variable ctx_weakref Undocumented
Property ctx Undocumented
def call(self, node, func, args, alias_map=None): (source)

Call this abstract value with the given arguments. The posargs and namedargs arguments may be modified by this function. Args: node: The CFGNode calling this function func: The cfg.Binding containing this function. args: Arguments for the call. alias_map: A datatypes.UnionFind, which stores all the type renaming information, mapping of type parameter name to its representative. Returns: A tuple (cfg.Node, cfg.Variable). The CFGNode corresponds to the function's "return" statement(s). Raises: function.FailedFunctionCall Make the call as required by this specific kind of atomic value, and make sure to annotate the results correctly with the origins (val and also other values appearing in the arguments).

def default_mro(self): (source)

Undocumented

def get_default_fullhash(self): (source)

Undocumented

def get_default_type_key(self): (source)

Gets a default type key. See get_type_key.

def get_formal_type_parameter(self, t): (source)

Get the class's type for the type parameter. Treating self as a class_mixin.Class, gets its formal type for the given type parameter. For the real implementation, see ParameterizedClass.get_formal_type_parameter. Args: t: The name of the type parameter. Returns: A formal type.

def get_instance_type(self, node=None, instance=None, seen=None, view=None): (source)

Get the type an instance of us would have.

def get_instance_type_parameter(self, name, node=None): (source)

Get a cfg.Variable of the instance's values for the type parameter. Treating self as an abstract.Instance, gets the variable of its values for the given type parameter. For the real implementation, see SimpleValue.get_instance_type_parameter. Args: name: The name of the type parameter. node: Optionally, the current CFG node. Returns: A Variable which may be empty.

def get_own_new(self, node, value): (source)

Get this value's __new__ method, if it isn't object.__new__.

def get_type_key(self, seen=None): (source)

Build a key from the information used to perform type matching. Get a hashable object containing this value's type information. Type keys are only compared amongst themselves, so we don't care what the internals look like, only that values with different types *always* have different type keys and values with the same type preferably have the same type key. Args: seen: The set of values seen before while computing the type key. Returns: A hashable object built from this value's type information.

def has_kwargs(self): (source)

Return True if this is a function and has a **kwargs parameter.

def has_varargs(self): (source)

Return True if this is a function and has a *args parameter.

def init_subclass(self, node, cls): (source)

Allow metaprogramming via __init_subclass__. We do not analyse __init_subclass__ methods in the code, but overlays that wish to replicate metaprogramming constructs using __init_subclass__ can define a class overriding this method, and ctx.make_class will call Class.call_init_subclass(), which will invoke the init_subclass() method for all classes in the list of base classes. This is here rather than in class_mixin.Class because a class's list of bases can include abstract objects that do not derive from Class (e.g. Unknown and Unsolvable). Args: node: cfg node cls: the abstract.InterpreterClass that is being constructed with subclass as a base Returns: A possibly new cfg node

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 is_late_annotation(self): (source)

Undocumented

@module.setter
def module(self, module): (source)

Undocumented

@official_name.setter
def official_name(self, official_name): (source)

Undocumented

def property_get(self, callself, is_class=False): (source)

Bind this value to the given self or cls. This function is similar to __get__ except at the abstract level. This does not trigger any code execution inside the VM. See __get__ for more details. Args: callself: The Variable that should be passed as self or cls when the call is made. We only need one of self or cls, so having them share a parameter prevents accidentally passing in both. is_class: Whether callself is self or cls. Should be cls only when we want to directly pass in a class to bind a class method to, rather than passing in an instance and calling get_class(). Returns: Another abstract value that should be returned in place of this one. The default implementation returns self, so this can always be called safely.

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)

def should_replace_self_annot(self): (source)

Undocumented

def to_annotation_container(self): (source)

Undocumented

def to_binding(self, node): (source)

Undocumented

def to_pytd_def(self, node, name): (source)

Get a PyTD definition for this object.

def to_type(self, node=None, seen=None, view=None): (source)

Get a PyTD type representing this object, as seen at a node.

def to_variable(self, node): (source)

Build a variable out of this abstract value. Args: node: The current CFG node. Returns: A cfg.Variable.

def unique_parameter_values(self): (source)

Get unique parameter subtypes as bindings. Like _unique_parameters, but returns bindings instead of variables. Returns: A list of list of bindings.

def update_official_name(self, _): (source)

Update the official name.

from_annotation = (source)

Undocumented

is_decorated: bool = (source)

Undocumented

Undocumented

@property
all_template_names = (source)

Undocumented

Undocumented

def _unique_parameters(self): (source)

Get unique parameter subtypes as variables. This will retrieve 'children' of this value that contribute to the type of it. So it will retrieve type parameters, but not attributes. To keep the number of possible combinations reasonable, when we encounter multiple instances of the same type, we include only one. Returns: A list of variables.

_all_template_names = (source)

Undocumented

Undocumented

_official_name = (source)

Undocumented