-
-
Notifications
You must be signed in to change notification settings - Fork 133
Closed
Labels
Description
- cattrs version: 22.1.0
- Python version: 3.11.0-rc1
- Operating System: Fedora Linux
Description
I would like an easy way to recursively generate attrs classes that have attributes of their type (eg Foo.foo: Foo). Obviously, you can't directly annotate attributes as being of the same type of the class, as the class is not yet generated when specifying attrs attributes. However, Python 3.11 introduces typing.Self, a shortcut to annotating the class. Cattrs could implement this, allowing users to avoid using __attrs_post_init__ to achieve this.
What I Did
# I would like to be able to do this:
@define
class Bar:
baz: typing.Self = None
@define
class Foo:
bar: Bar
structure({"bar": {"baz": {"baz": None}}}, Foo)Reactions are currently unavailable