class PyTDClass(_instance_base.SimpleValue, class_mixin.Class, mixin.LazyMembers): (source)
Known subclasses: pytype.abstract._classes.FunctionPyTDClass
, pytype.overlays.enum_overlay.EnumBuilder
, pytype.overlays.enum_overlay.EnumMeta
, pytype.overlays.flax_overlay.Module
, pytype.overlays.named_tuple.NamedTupleClassBuilder
, pytype.overlays.special_builtins.BuiltinClass
, pytype.overlays.subprocess_overlay.Popen
, pytype.overlays.typed_dict.TypedDictBuilder
, pytype.overlays.typed_dict.TypedDictClass
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 |
Convert `name` as an instance attribute. |
Method | get |
Get the abstract methods defined by this class. |
Method | get |
Get the attributes defined by this class. |
Method | has |
Returns whether this class inherits directly from typing.Protocol. |
Method | instantiate |
Create an instance of self. |
Method | load |
Load the named attribute into self.members. |
Instance Variable | final |
Undocumented |
Instance Variable | final |
Undocumented |
Instance Variable | has |
Undocumented |
Instance Variable | is |
Undocumented |
Instance Variable | pytd |
Undocumented |
Instance Variable | slots |
Undocumented |
Method | _convert |
Convert a member as a variable. For lazy lookup. |
Method | _init |
Initialise metadata[key] with a list of Attributes. |
Method | _new |
Returns a (possibly cached) instance of 'self'. |
Method | _populate |
Fill in class attribute metadata for decorators like @dataclass. |
Method | _recompute |
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 |
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 | 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
(via SimpleValue
):
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 | from |
Undocumented |
Instance Variable | is |
Undocumented |
Instance Variable | is |
Undocumented |
Instance Variable | mro |
Undocumented |
Instance Variable | name |
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 SimpleValue
, BaseValue
):
Class Variable | __slots__ |
Undocumented |
Instance Variable | ctx |
Undocumented |
Property | ctx |
Undocumented |
Inherited from Class
(via SimpleValue
, BaseValue
, ContextWeakrefMixin
):
Method | __new__ |
Prevent direct instantiation. |
Method | call |
Undocumented |
Method | call |
Call init_subclass(cls) for all base classes. |
Method | call |
Call the metaclass's __init__ method if it does anything interesting. |
Method | compute |
Sets combined metadata based on inherited and own attrs. |
Method | compute |
Undocumented |
Method | get |
Undocumented |
Method | has |
Undocumented |
Method | init |
Mix-in equivalent of __init__. |
Method | is |
Undocumented |
Method | record |
Records the order of attrs to write in the output pyi. |
Class Variable | overloads |
Undocumented |
Instance Variable | abstract |
Undocumented |
Instance Variable | additional |
Undocumented |
Instance Variable | metadata |
Undocumented |
Instance Variable | overrides |
Undocumented |
Instance Variable | protocol |
Undocumented |
Property | all |
Undocumented |
Property | annotations |
Undocumented |
Property | is |
Undocumented |
Property | is |
Undocumented |
Property | is |
Undocumented |
Property | is |
Undocumented |
Method | _call |
Undocumented |
Method | _call |
Call __new__ if it has been overridden on the given value. |
Method | _check |
Report [not-instantiable] if the class cannot be instantiated. |
Method | _get |
Traverse the MRO and collect base class attributes for metadata_key. |
Method | _get |
Undocumented |
Method | _get |
Traverse the MRO and collect base class attributes for metadata_key. |
Method | _has |
Undocumented |
Method | _has |
Whether the class should be considered implicitly abstract. |
Method | _init |
Compute this class's abstract methods. |
Method | _init |
Compute and cache whether the class sets its own boolean value. |
Method | _init |
Compute this class's protocol attributes. |
Method | _load |
Load _all_formal_type_parameters. |
Method | _recompute |
Traverse the MRO and apply Generic type params to class attributes. |
Instance Variable | _all |
Undocumented |
Instance Variable | _all |
Undocumented |
Instance Variable | _instance |
Undocumented |
Inherited from LazyMembers
(via SimpleValue
, BaseValue
, ContextWeakrefMixin
, Class
):
Instance Variable | _member |
Undocumented |
pytype.abstract._classes.FunctionPyTDClass
, pytype.overlays.enum_overlay.EnumBuilder
, pytype.overlays.enum_overlay.EnumMeta
, pytype.overlays.flax_overlay.Module
, pytype.overlays.named_tuple.NamedTupleClassBuilder
, pytype.overlays.special_builtins.BuiltinClass
, pytype.overlays.subprocess_overlay.Popen
, pytype.overlays.typed_dict.TypedDictBuilder
, pytype.overlays.typed_dict.TypedDictClass
Initialize a SimpleValue. Args: name: Name of this value. For debugging and error reporting. ctx: The abstract context.
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.
Returns whether this class inherits directly from typing.Protocol. Subclasses that may inherit from Protocol should override this method.
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.overlays.typed_dict.TypedDictClass
Returns a (possibly cached) instance of 'self'.