Class | Attribute |
The value of an attr.ib() call. |
Class | Converter |
Holds information about a converter= argument |
Class | MethodAdder |
Helper to add methods to a TypeInfo. |
Function | attr_class_maker_callback |
Add necessary dunder methods to classes decorated with attr.s. |
Function | is_valid_overloaded_converter |
Undocumented |
Constant | attr_attrib_makers |
Undocumented |
Constant | attr_class_makers |
Undocumented |
Constant | attr_dataclass_makers |
Undocumented |
Constant | attr_define_makers |
Undocumented |
Constant | attr_frozen_makers |
Undocumented |
Constant | KW_ONLY_PYTHON_2_UNSUPPORTED |
Undocumented |
Constant | SELF_TVAR_NAME |
Undocumented |
Function | _add_attrs_magic_attribute |
Undocumented |
Function | _add_init |
Generate an __init__ method for the attributes and add it to the class. |
Function | _add_order |
Generate all the ordering methods for this class. |
Function | _add_slots |
Undocumented |
Function | _analyze_class |
Analyze the class body of an attr maker, its parents, and return the Attributes found. |
Function | _attribute_from_attrib_maker |
Return an Attribute from the assignment or None if you can't make one. |
Function | _attribute_from_auto_attrib |
Return an Attribute for a new type assignment. |
Function | _attributes_from_assignment |
Return Attribute objects that are created by this assignment. |
Function | _cleanup_decorator |
Handle decorators in class bodies. |
Function | _detect_auto_attribs |
Return whether auto_attribs should be enabled or disabled. |
Function | _determine_eq_order |
Validate the combination of cmp, eq, and order. Derive the effective value of order. |
Function | _get_decorator_optional_bool_argument |
Return the Optional[bool] argument for the decorator. |
Function | _get_frozen |
Return whether this class is frozen. |
Function | _make_frozen |
Turn all the attributes into properties to simulate frozen classes. |
Function | _parse_assignments |
Convert a possibly complex assignment expression into lists of lvalues and rvalues. |
Function | _parse_converter |
Return the Converter object from an Expression. |
Add necessary dunder methods to classes decorated with attr.s.
attrs is a package that lets you define classes without writing dull boilerplate code.
At a quick glance, the decorator searches the class body for assignments of `attr.ib`s (or annotated variables if auto_attribs=True), then depending on how the decorator is called, it will add an __init__ or all the __cmp__ methods. For frozen=True it will turn the attrs into properties.
See http://www.attrs.org/en/stable/how-does-it-work.html for information on how attrs works.
Parameters | |
ctx:mypy.plugin.ClassDefContext | Undocumented |
auto_attribs_default:Optional[ | Undocumented |
frozen_default:bool | Undocumented |
Undocumented
Parameters | |
ctx:mypy.plugin.ClassDefContext | Undocumented |
raw_attr_types:List[ | Undocumented |
Parameters | |
ctx:mypy.plugin.ClassDefContext | Undocumented |
attributes:List[ | Undocumented |
adder:MethodAdder | Undocumented |
Parameters | |
ctx:mypy.plugin.ClassDefContext | Undocumented |
adder:MethodAdder | Undocumented |
Undocumented
Parameters | |
ctx:mypy.plugin.ClassDefContext | Undocumented |
attributes:List[ | Undocumented |
Analyze the class body of an attr maker, its parents, and return the Attributes found.
auto_attribs=True means we'll generate attributes from type annotations also. auto_attribs=None means we'll detect which mode to use. kw_only=True means that all attributes created here will be keyword only args in __init__.
Parameters | |
ctx:mypy.plugin.ClassDefContext | Undocumented |
auto_attribs:Optional[ | Undocumented |
kw_only:bool | Undocumented |
Returns | |
List[ | Undocumented |
Parameters | |
ctx:mypy.plugin.ClassDefContext | Undocumented |
auto_attribs:bool | Undocumented |
kw_only:bool | Undocumented |
lhs:NameExpr | Undocumented |
rvalue:CallExpr | Undocumented |
stmt:AssignmentStmt | Undocumented |
Returns | |
Optional[ | Undocumented |
Parameters | |
ctx:mypy.plugin.ClassDefContext | Undocumented |
kw_only:bool | Undocumented |
lhs:NameExpr | Undocumented |
rvalue:Expression | Undocumented |
stmt:AssignmentStmt | Undocumented |
Returns | |
Attribute | Undocumented |
Return Attribute objects that are created by this assignment.
Parameters | |
ctx:mypy.plugin.ClassDefContext | Undocumented |
stmt:AssignmentStmt | Undocumented |
auto_attribs:bool | Undocumented |
kw_only:bool | Undocumented |
Returns | |
Iterable[ | Undocumented |
Return whether auto_attribs should be enabled or disabled.
It's disabled if there are any unannotated attribs()
Parameters | |
ctx:mypy.plugin.ClassDefContext | Undocumented |
Returns | |
bool | Undocumented |
Parameters | |
ctx:mypy.plugin.ClassDefContext | Undocumented |
Returns | |
bool | Undocumented |
Return the Optional[bool] argument for the decorator.
This handles both @decorator(...) and @decorator.
Parameters | |
ctx:mypy.plugin.ClassDefContext | Undocumented |
name:str | Undocumented |
default:Optional[ | Undocumented |
Returns | |
Optional[ | Undocumented |
Parameters | |
ctx:mypy.plugin.ClassDefContext | Undocumented |
frozen_default:bool | Undocumented |
Returns | |
bool | Undocumented |
Parameters | |
ctx:mypy.plugin.ClassDefContext | Undocumented |
attributes:List[ | Undocumented |
Parameters | |
lvalue:Expression | Undocumented |
stmt:AssignmentStmt | Undocumented |
Returns | |
Tuple[ | Undocumented |
Parameters | |
ctx:mypy.plugin.ClassDefContext | Undocumented |
converter:Optional[ | Undocumented |
Returns | |
Converter | Undocumented |