class DataclassTransformer: (source)
Undocumented
Method | __init__ |
Undocumented |
Method | add_slots |
Undocumented |
Method | collect_attributes |
Collect all attributes declared in the dataclass and its parents. |
Method | reset_init_only_vars |
Remove init-only vars from the class and reset init var declarations. |
Method | transform |
Apply all the necessary transformations to the underlying dataclass so as to ensure it is fully type checked according to the rules in PEP 557. |
Method | _add_dataclass_fields_magic_attribute |
Undocumented |
Method | _freeze |
Converts all attributes to @property methods in order to emulate frozen classes. |
Method | _is_kw_only_type |
Checks if the type of the node is the KW_ONLY sentinel value. |
Method | _propertize_callables |
Converts all attributes with callable types to @property methods. |
Instance Variable | _ctx |
Undocumented |
Undocumented
Parameters | |
info:TypeInfo | Undocumented |
attributes:List[ | Undocumented |
correct_version:bool | Undocumented |
Collect all attributes declared in the dataclass and its parents.
All assignments of the form
a: SomeType b: SomeOtherType = ...
are collected.
Returns | |
Optional[ | Undocumented |
Parameters | |
info:TypeInfo | Undocumented |
attributes:List[ | Undocumented |
Parameters | |
attributes:List[ | Undocumented |
Parameters | |
node:Optional[ | Undocumented |
Returns | |
bool | Undocumented |
Converts all attributes with callable types to @property methods.
This avoids the typechecker getting confused and thinking that
my_dataclass_instance.callable_attr(foo)
is going to receive a
self
argument (it is not).
Parameters | |
attributes:List[ | Undocumented |