[issue46757] dataclasses should define an empty __post_init__

Neil Girdhar report at bugs.python.org
Wed Feb 23 01:24:18 EST 2022


Neil Girdhar <mistersheik at gmail.com> added the comment:

@eric

Good thinking.  Would it make sense to add to the documentation as well that the __post_init__ methods aren't collected, and you should call super's __post_init__ if there is one using something like

        if hasattr(super(), "__post_init__"):
            super().__post_init__()

Noting this will make it easier to point to the docs if someone wonders when they see code like this.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue46757>
_______________________________________


More information about the Python-bugs-list mailing list