![]() * Clarify next-gen auto_attribs inference rules The next-gen auto_attribs api documentation does not clearly describe cases where (a) only a subset of attributes are annotated and (b) `field` definitions are provided for a subset of fields. Update docstring to reflect current, desirable, behavior. Add tests to clarify `.define` behavior focused on fully-annotated classes with partially-defined fields, which is commonly used to add non-default behavior to a subset of a classes fields. For example: ```python @attr.define class NewSchool: x: int y: list = attr.field() @y.validator def _validate_y(self, attribute, value): if value < 0: raise ValueError("y must be positive") ``` The previous docstring *could* be read to imply that: * The new-school API will not infer auto_attribs if there are any unannotated attributes. * The new-school API will not infer auto_attribs if *any* attr.ib are defined, even if those attr.ibs are type annotated. * Update test to match PR example * Fix lint error Co-authored-by: Hynek Schlawack <hs@ox.cx> |
||
---|---|---|
.. | ||
__init__.py | ||
strategies.py | ||
test_annotations.py | ||
test_config.py | ||
test_converters.py | ||
test_dunders.py | ||
test_filters.py | ||
test_funcs.py | ||
test_functional.py | ||
test_hooks.py | ||
test_init_subclass.py | ||
test_make.py | ||
test_mypy.yml | ||
test_next_gen.py | ||
test_setattr.py | ||
test_slots.py | ||
test_validators.py | ||
test_version_info.py | ||
typing_example.py | ||
utils.py |