Please consider making dataclasses define an empty __post_init__
Feb. 20, 2022
2:47 p.m.
This was discussed here: https://bugs.python.org/issue46757 This came up because I had a dataclass subclass to flax.linen.Module that had its own post-init. When I figured out that I needed to call super, I did so. Later, when I refactored my code to remove the superclass, the super-call was broken. It have been much simpler to always call super in __post_init__ from the start. The proposal on the bug report was to get in the habit of doing: if hasattr(super(), "__post_init__"): super().__post_init__() or: try: post_init = super().__post_init__ except AttributeError: pass else: post_init() I think it will be difficult to convince projects to do this. Best, Neil
1071
Age (days ago)
1071
Last active (days ago)
0 comments
1 participants
participants (1)
-
Neil Girdhar