class BaseValue(utils.ContextWeakrefMixin): (source)
Known subclasses: pytype.abstract._classes.BuildClass
, pytype.abstract._classes.ParameterizedClass
, pytype.abstract._function_base.BoundFunction
, pytype.abstract._function_base.ClassMethod
, pytype.abstract._function_base.Property
, pytype.abstract._function_base.StaticMethod
, pytype.abstract._instance_base.SimpleValue
, pytype.abstract._instances.SequenceLength
, pytype.abstract._instances.Splat
, pytype.abstract._singletons.Singleton
, pytype.abstract._singletons.Unknown
, pytype.abstract._typing.Concatenate
, pytype.abstract._typing.FinalAnnotation
, pytype.abstract._typing.ParamSpecArgs
, pytype.abstract._typing.ParamSpecKwargs
, pytype.abstract._typing.Union
, pytype.abstract.function.ParamSpecMatch
, pytype.overlays.metaclass.AddMetaclassInstance
, pytype.overlays.metaclass.WithMetaclassInstance
, pytype.overlays.special_builtins.RevealType
, pytype.overlays.special_builtins.SuperInstance
, pytype.abstract._typing._TypeVariable
, pytype.abstract._typing._TypeVariableInstance
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 |
Undocumented |
Method | default |
Undocumented |
Method | get |
Undocumented |
Method | get |
Gets a default type key. See get_type_key. |
Method | get |
Get the class's type for the type parameter. |
Method | get |
Undocumented |
Method | get |
Get the type an instance of us would have. |
Method | get |
Get a cfg.Variable of the instance's values for the type parameter. |
Method | get |
Get this value's __new__ method, if it isn't object.__new__. |
Method | get |
Fetch a special attribute (e.g., __get__, __iter__). |
Method | get |
Build a key from the information used to perform type matching. |
Method | has |
Return True if this is a function and has a **kwargs parameter. |
Method | has |
Return True if this is a function and has a *args parameter. |
Method | init |
Allow metaprogramming via __init_subclass__. |
Method | instantiate |
Create an instance of self. |
Method | is |
Undocumented |
Method | module |
Undocumented |
Method | official |
Undocumented |
Method | property |
Bind this value to the given self or cls. |
Method | register |
Treating self as a class definition, register an instance of it. |
Method | should |
Undocumented |
Method | to |
Undocumented |
Method | to |
Undocumented |
Method | to |
Get a PyTD definition for this object. |
Method | to |
Get a PyTD type representing this object, as seen at a node. |
Method | to |
Build a variable out of this abstract value. |
Method | unique |
Get unique parameter subtypes as bindings. |
Method | update |
Update the official name. |
Class Variable | formal |
Undocumented |
Instance Variable | cls |
Undocumented |
Instance Variable | final |
Undocumented |
Instance Variable | from |
Undocumented |
Instance Variable | is |
Undocumented |
Instance Variable | is |
Undocumented |
Instance Variable | mro |
Undocumented |
Instance Variable | name |
Undocumented |
Instance Variable | slots |
Undocumented |
Property | all |
Undocumented |
Property | full |
Undocumented |
Property | module |
Undocumented |
Property | official |
Undocumented |
Property | template |
Undocumented |
Method | _unique |
Get unique parameter subtypes as variables. |
Instance Variable | _all |
Undocumented |
Instance Variable | _instance |
Undocumented |
Instance Variable | _module |
Undocumented |
Instance Variable | _official |
Undocumented |
Instance Variable | _template |
Undocumented |
Inherited from ContextWeakrefMixin
:
Class Variable | __slots__ |
Undocumented |
Instance Variable | ctx |
Undocumented |
Property | ctx |
Undocumented |
pytype.abstract._classes.BuildClass
, pytype.abstract._classes.ParameterizedClass
, pytype.abstract._function_base.BoundFunction
, pytype.abstract._function_base.ClassMethod
, pytype.abstract._function_base.Property
, pytype.abstract._function_base.StaticMethod
, pytype.abstract._instance_base.SimpleValue
, pytype.abstract._instances.SequenceLength
, pytype.abstract._instances.Splat
, pytype.abstract._singletons.Empty
, pytype.abstract._singletons.Unknown
, pytype.abstract._singletons.Unsolvable
, pytype.abstract._typing.Concatenate
, pytype.abstract._typing.FinalAnnotation
, pytype.abstract._typing.ParamSpecArgs
, pytype.abstract._typing.ParamSpecKwargs
, pytype.abstract._typing.Union
, pytype.abstract.function.ParamSpecMatch
, pytype.overlays.metaclass.AddMetaclassInstance
, pytype.overlays.metaclass.WithMetaclassInstance
, pytype.overlays.special_builtins.RevealType
, pytype.overlays.special_builtins.SuperInstance
, pytype.overlays.typing_overlay.NoReturn
, pytype.abstract._typing._TypeVariable
, pytype.abstract._typing._TypeVariableInstance
Basic initializer for all BaseValues.
pytype.abstract._classes.ParameterizedClass
, pytype.abstract._function_base.BoundFunction
, pytype.abstract._instance_base.SimpleValue
, pytype.abstract._instances.SequenceLength
, pytype.abstract._instances.Splat
, pytype.abstract._typing.Concatenate
, pytype.abstract._typing.FinalAnnotation
, pytype.abstract._typing.Union
, pytype.abstract._typing._TypeVariable
, pytype.abstract._typing._TypeVariableInstance
Undocumented
pytype.abstract._function_base.BoundFunction
, pytype.abstract._instance_base.SimpleValue
, pytype.abstract._singletons.Unknown
, pytype.abstract._singletons.Unsolvable
Returns the minimum number of arguments needed for a call.
pytype.abstract._classes.BuildClass
, pytype.abstract._classes.ParameterizedClass
, pytype.abstract._function_base.BoundFunction
, pytype.abstract._function_base.ClassMethod
, pytype.abstract._function_base.Property
, pytype.abstract._function_base.StaticMethod
, pytype.abstract._instance_base.SimpleValue
, pytype.abstract._singletons.Singleton
, pytype.abstract._singletons.Unknown
, pytype.abstract._typing.Union
, pytype.overlays.metaclass.AddMetaclassInstance
, pytype.overlays.special_builtins.RevealType
, pytype.overlays.special_builtins.SuperInstance
, pytype.abstract._typing._TypeVariable
, pytype.abstract._typing._TypeVariableInstance
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).
pytype.abstract._classes.ParameterizedClass
, pytype.abstract._singletons.Singleton
, pytype.abstract._singletons.Unknown
Undocumented
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.
pytype.abstract._instance_base.SimpleValue
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.
pytype.abstract._classes.CallableClass
, pytype.abstract._classes.TupleClass
, pytype.abstract._function_base.BoundFunction
, pytype.abstract._instances.Generator
, pytype.abstract._singletons.Singleton
, pytype.abstract._singletons.Unknown
, pytype.overlays.special_builtins.Object
, pytype.overlays.special_builtins.SuperInstance
, pytype.overlays.subprocess_overlay.Popen
, pytype.overlays.sys_overlay.VersionInfo
Fetch a special attribute (e.g., __get__, __iter__).
pytype.abstract._instance_base.SimpleValue
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.
pytype.abstract._function_base.BoundFunction
, pytype.abstract._interpreter_function.InterpreterFunction
Return True if this is a function and has a **kwargs parameter.
pytype.abstract._function_base.BoundFunction
, pytype.abstract._interpreter_function.InterpreterFunction
Return True if this is a function and has a *args parameter.
pytype.overlays.flax_overlay.Module
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
pytype.abstract._classes.ParameterizedClass
, pytype.abstract._instance_base.SimpleValue
, pytype.abstract._instances.SequenceLength
, pytype.abstract._singletons.Singleton
, pytype.abstract._singletons.Unknown
, pytype.abstract._typing.Concatenate
, pytype.abstract._typing.FinalAnnotation
, pytype.abstract._typing.ParamSpecArgs
, pytype.abstract._typing.ParamSpecKwargs
, pytype.abstract._typing.Union
, pytype.abstract.function.ParamSpecMatch
, pytype.abstract._typing._TypeVariable
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.
pytype.abstract._function_base.Function
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.
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)
pytype.abstract._singletons.Unknown
Build a variable out of this abstract value. Args: node: The current CFG node. Returns: A cfg.Variable.
Get unique parameter subtypes as bindings. Like _unique_parameters, but returns bindings instead of variables. Returns: A list of list of bindings.
pytype.abstract._classes.ParameterizedClass
, pytype.abstract._function_base.BoundFunction
, pytype.abstract._function_base.ClassMethod
, pytype.abstract._function_base.Property
, pytype.abstract._function_base.StaticMethod
, pytype.abstract._instance_base.SimpleValue
, pytype.abstract._instances.Splat
, pytype.abstract._typing.Union
, pytype.overlays.special_builtins.SuperInstance
, pytype.overlays.typing_overlay.NoReturn
, pytype.abstract._typing._TypeVariableInstance
Undocumented
pytype.abstract._classes.InterpreterClass
, pytype.abstract._classes.ParameterizedClass
, pytype.abstract._classes.PyTDClass
Undocumented
pytype.abstract._instance_base.Instance
, pytype.abstract._typing.Concatenate
, pytype.overlays.flax_overlay.Module
Undocumented
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.
pytype.abstract._classes.LiteralClass
, pytype.abstract._classes.TupleClass
, pytype.abstract._singletons.Singleton
Undocumented