From fe7ebb0b97ef77b9231a2eb56e69f61398623b18 Mon Sep 17 00:00:00 2001 From: Hynek Schlawack Date: Wed, 21 Feb 2024 08:26:01 +0100 Subject: [PATCH] Add example of type-less class --- README.md | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a198105..52c5c2a3 100644 --- a/README.md +++ b/README.md @@ -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) +``` ---