Nikita Sobolev <[email protected]> added the comment:
I like this idea.
`attrs` right now behave the same way (no default `__attrs_post_init__`:
```
>>> import attrs
>>> @attrs.define
... class Some:
... x: int
...
>>> @attrs.define
... class Other(Some):
... def __attrs_post_init__(self):
... super().__attrs_post_init__()
... self.x += 1
...
>>> Other(1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<attrs generated init __main__.Other>", line 3, in __init__
File "<stdin>", line 4, in __attrs_post_init__
AttributeError: 'super' object has no attribute '__attrs_post_init__'
```
I am attaching a simple patch.
Alternative solution is to not merge this patch and recommend this instead:
```
def __post_init__(self):
try:
super().__post_init__()
except AttributeError:
pass
```
----------
nosy: +sobolevn
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue46757>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com