Astroid hook for the dataclasses library
Support built-in dataclasses, pydantic.dataclasses, and marshmallow_dataclass-annotated dataclasses. References: - https://docs.python.org/3/library/dataclasses.html - https://pydantic-docs.helpmanual.io/usage/dataclasses/ - https://lovasoa.github.io/marshmallow_dataclass/
Function | dataclass_transform |
Rewrite a dataclass to be easily understood by pylint |
Function | infer_dataclass_attribute |
Inference tip for an Unknown node that was dynamically generated to represent a dataclass attribute. |
Function | infer_dataclass_field_call |
Inference tip for dataclass field calls. |
Function | is_decorated_with_dataclass |
Return True if a decorated node has a dataclass decorator applied. |
Constant | DATACLASS_MODULES |
Undocumented |
Constant | DATACLASSES_DECORATORS |
Undocumented |
Constant | DEFAULT_FACTORY |
Undocumented |
Constant | FIELD_NAME |
Undocumented |
Function | _check_generate_dataclass_init |
Return True if we should generate an __init__ method for node. |
Function | _generate_dataclass_init |
Return an init method for a dataclass given the targets. |
Function | _get_dataclass_attributes |
Yield the AnnAssign nodes of dataclass attributes for the node. |
Function | _get_field_default |
Return a the default value of a field call, and the corresponding keyword argument name. |
Function | _infer_instance_from_annotation |
Infer an instance corresponding to the type annotation represented by node. |
Function | _is_class_var |
Return True if node is a ClassVar, with or without subscripting. |
Function | _is_init_var |
Return True if node is an InitVar, with or without subscripting. |
Function | _looks_like_dataclass_attribute |
Return True if node was dynamically generated as the child of an AnnAssign statement. |
Function | _looks_like_dataclass_decorator |
Return True if node looks like a dataclass decorator. |
Function | _looks_like_dataclass_field_call |
Return True if node is calling dataclasses field or Field from an AnnAssign statement directly in the body of a ClassDef. |
Constant | _INFERABLE_TYPING_TYPES |
Undocumented |
Variable | _FieldDefaultReturn |
Undocumented |
Inference tip for an Unknown node that was dynamically generated to represent a dataclass attribute.
In the case that a default value is provided, that is inferred first. Then, an Instance of the annotated class is yielded.
Parameters | |
node:Unknown | Undocumented |
ctx:Optional[ | Undocumented |
Returns | |
Generator | Undocumented |
Parameters | |
node:Call | Undocumented |
ctx:Optional[ | Undocumented |
Returns | |
Generator | Undocumented |
Undocumented
Value |
|
Return True if we should generate an __init__ method for node.
Parameters | |
node:ClassDef | Undocumented |
Returns | |
bool | Undocumented |
Parameters | |
assigns:List[ | Undocumented |
Returns | |
str | Undocumented |
Yield the AnnAssign nodes of dataclass attributes for the node.
If init is True, also include InitVars, but exclude attributes from calls to field where init=False.
Parameters | |
node:ClassDef | Undocumented |
init:bool | Undocumented |
Returns | |
Generator | Undocumented |
Return a the default value of a field call, and the corresponding keyword argument name.
field(default=...) results in the ... node field(default_factory=...) results in a Call node with func ... and no arguments
If neither or both arguments are present, return ("", None) instead, indicating that there is not a valid default value.
Parameters | |
field_call:Call | Undocumented |
Returns | |
_FieldDefaultReturn | Undocumented |
Infer an instance corresponding to the type annotation represented by node.
Currently has limited support for the typing module.
Parameters | |
node:NodeNG | Undocumented |
ctx:Optional[ | Undocumented |
Returns | |
Generator | Undocumented |
Parameters | |
node:NodeNG | Undocumented |
Returns | |
bool | Undocumented |
Parameters | |
node:NodeNG | Undocumented |
Returns | |
bool | Undocumented |
Parameters | |
node:Unknown | Undocumented |
Returns | |
bool | Undocumented |
Return True if node looks like a dataclass decorator.
Uses inference to lookup the value of the node, and if that fails, matches against specific names.
Parameters | |
node:NodeNG | Undocumented |
decorator_names:FrozenSet[ | Undocumented |
Returns | |
bool | Undocumented |
Return True if node is calling dataclasses field or Field from an AnnAssign statement directly in the body of a ClassDef.
If check_scope is False, skips checking the statement and body.
Parameters | |
node:Call | Undocumented |
check_scope:bool | Undocumented |
Returns | |
bool | Undocumented |
Undocumented
Value |
|