Add example of type-less class

This commit is contained in:
Hynek Schlawack 2024-02-21 08:26:01 +01:00
parent 18040f5f25
commit fe7ebb0b97
No known key found for this signature in database
1 changed files with 10 additions and 1 deletions

View File

@ -94,7 +94,16 @@ After *declaring* your attributes, *attrs* gives you:
**Hate type annotations**!?
No problem!
Types are entirely **optional** with *attrs*.
Simply assign `attrs.field()` to the attributes instead of annotating them with types.
Simply assign `attrs.field()` to the attributes instead of annotating them with types:
```python
from attrs import define, field
@define
class SomeClass:
a_number = field(default=42)
list_of_numbers = field(factory=list)
```
---