class SimpleValue(_base.BaseValue): (source)
Known subclasses: pytype.abstract._classes.InterpreterClass
, pytype.abstract._classes.PyTDClass
, pytype.abstract._function_base.Function
, pytype.abstract._instance_base.Instance
, pytype.abstract._instances.LazyConcreteDict
, pytype.abstract._typing.AnnotationClass
, pytype.overlays.attr_overlay.AttribInstance
, pytype.overlays.dataclass_overlay.FieldInstance
A basic abstract value that represents instances. This class implements instances in the Python sense. Instances of the same class may vary. Note that the cls attribute will point to another abstract value that represents the class object itself, not to some special type representation. Attributes: members: A name->value dictionary of the instance's attributes.
Method | __init__ |
Initialize a SimpleValue. |
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 | cls |
Undocumented |
Method | get |
Undocumented |
Method | get |
Get a cfg.Variable of the instance's values for the type parameter. |
Method | get |
Build a key from the information used to perform type matching. |
Method | has |
Check if the key is in `instance_type_parameters`. |
Method | instantiate |
Create an instance of self. |
Method | maybe |
Undocumented |
Method | merge |
Set the value of a type parameter. |
Method | set |
Set the __class__ of an instance, for code that does "x.__class__ = y. |
Method | update |
Undocumented |
Instance Variable | members |
Undocumented |
Property | cls |
Undocumented |
Property | instance |
Undocumented |
Property | maybe |
Undocumented |
Method | _call |
Undocumented |
Method | _get |
Undocumented |
Method | _get |
Undocumented |
Method | _unique |
Get unique parameter subtypes as variables. |
Instance Variable | _cached |
Undocumented |
Instance Variable | _cls |
Undocumented |
Instance Variable | _fullhash |
Undocumented |
Instance Variable | _instance |
Undocumented |
Instance Variable | _maybe |
Undocumented |
Instance Variable | _type |
Undocumented |
Inherited from BaseValue
:
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 |
Get the type an instance of us would have. |
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 | 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 | 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 | 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 |
Instance Variable | _all |
Undocumented |
Instance Variable | _instance |
Undocumented |
Instance Variable | _module |
Undocumented |
Instance Variable | _official |
Undocumented |
Instance Variable | _template |
Undocumented |
Inherited from ContextWeakrefMixin
(via BaseValue
):
Class Variable | __slots__ |
Undocumented |
Instance Variable | ctx |
Undocumented |
Property | ctx |
Undocumented |
pytype.abstract._base.BaseValue.__init__
pytype.abstract._classes.InterpreterClass
, pytype.abstract._classes.PyTDClass
, pytype.abstract._function_base.Function
, pytype.abstract._instance_base.Instance
, pytype.abstract._instances.LazyConcreteDict
, pytype.abstract._typing.AnnotationClass
, pytype.overlays.attr_overlay.AttribInstance
, pytype.overlays.dataclass_overlay.FieldInstance
Initialize a SimpleValue. Args: name: Name of this value. For debugging and error reporting. ctx: The abstract context.
pytype.abstract._base.BaseValue.__repr__
pytype.abstract._classes.InterpreterClass
, pytype.abstract._classes.PyTDClass
, pytype.abstract._function_base.Function
, pytype.abstract._instances.Dict
, pytype.abstract._instances.List
, pytype.abstract._typing.AnnotationClass
Undocumented
pytype.abstract._base.BaseValue.argcount
pytype.abstract._function_base.NativeFunction
, pytype.abstract._function_base.SignedFunction
, pytype.abstract._pytd_function.PyTDFunction
Returns the minimum number of arguments needed for a call.
pytype.abstract._base.BaseValue.call
pytype.abstract._function_base.NativeFunction
, pytype.abstract._function_base.SimpleFunction
, pytype.abstract._instances.BaseGenerator
, pytype.abstract._interpreter_function.InterpreterFunction
, pytype.abstract._pytd_function.PyTDFunction
, pytype.abstract._typing.AnnotationContainer
, pytype.overlays.enum_overlay.EnumBuilder
, pytype.overlays.named_tuple.NamedTupleClassBuilder
, pytype.overlays.special_builtins.ClassMethodTemplate
, pytype.overlays.special_builtins.Dict
, pytype.overlays.special_builtins.PropertyTemplate
, pytype.overlays.special_builtins.StaticMethodTemplate
, pytype.overlays.special_builtins.Super
, pytype.overlays.typed_dict.TypedDictBuilder
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).
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.
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._classes.InterpreterClass
, pytype.abstract._classes.PyTDClass
, pytype.overlays.typing_overlay.Final
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._instances.List
Set the value of a type parameter. This will always add to the type parameter unlike set_attribute which will replace value from the same basic block. This is because type parameters may be affected by a side effect so we need to collect all the information regardless of multiple assignments in one basic block. Args: node: Optionally, the current CFG node. name: The name of the type parameter. value: The value that is being used for this type parameter as a Variable.
pytype.abstract._instances.Tuple
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.