Base support for generating classes from data declarations. Contains common functionality used by dataclasses, attrs and namedtuples.
Class |
|
Base class for decorators that generate classes from data declarations. |
Class |
|
Implements constructors for fields. |
Class |
|
Possible orderings for get_class_locals. |
Function | add |
Undocumented |
Function | get |
Gets a dictionary of the class's local variables. |
Function | get |
Get __annotations__ from members map, create and attach it if not present. |
Function | is |
Undocumented |
Function | is |
Undocumented |
Function | is |
Tests whether the current class local could be relevant for type checking. |
Function | make |
Create a replace() method for a dataclass. |
Variable | log |
Undocumented |
Gets a dictionary of the class's local variables. Args: cls_name: The name of an abstract.InterpreterClass. allow_methods: A bool, whether to allow methods as variables. ordering: A classgen.Ordering describing the order in which the variables should appear. ctx: The abstract context. Returns: A collections.OrderedDict of the locals.
Get __annotations__ from members map, create and attach it if not present. The returned dict is also referenced by members, so it is safe to mutate. Args: members: A dict of member name to variable. ctx: context.Context instance. Returns: members['__annotations__'] unpacked as a python dict
abstract_utils.Local
, class_local_name: str
, allow_methods: bool
):
(source)
¶
Tests whether the current class local could be relevant for type checking. For example, this doesn't match __dunder__ class locals. To get an abstract_utils.Local from a vm.LocalOps, you can use, 'vm_instance.annotated_locals[cls_name][op.name]'. Args: class_local: the local to query class_local_name: the name of the class local (because abstract_utils.Local does not hold this information). allow_methods: whether to allow methods class locals to match Returns: Whether this class local could possibly be relevant for type checking. Callers will usually want to filter even further.