Message413588
> How would an arbitrary derived class know how to call this? It can't. There has to be knowledge of the base class's requirements already. Surely knowing "__post_init__ must be called with some_arg" isn't too different from "I know __post_init__ doesn't exist".
This is exactly the same problem you have with all other "augmenting methods" that have arbitrary parameters (e.g., __init__). When calling super on a non-final class you could simply forward keyword arguments.
@dataclass
class X:
def __post_init__(self, **kwargs):
super().__post_init__(**kwargs)
...
@dataclass
class Y(X):
def __post_init__(self, **kwargs):
super().__post_init__(**kwargs)
...
> I'm still unconvinced, but I'll hold off on making a decision to see if there's more support. Maybe taking it to python-ideas would be worthwhile.
Sounds good, done: https://groups.google.com/g/python-ideas/c/-gctNaSqgew |
|
Date |
User |
Action |
Args |
2022-02-20 14:48:08 | NeilGirdhar | set | recipients:
+ NeilGirdhar, eric.smith, veky, sobolevn |
2022-02-20 14:48:08 | NeilGirdhar | set | messageid: <1645368488.65.0.17304007841.issue46757@roundup.psfhosted.org> |
2022-02-20 14:48:08 | NeilGirdhar | link | issue46757 messages |
2022-02-20 14:48:08 | NeilGirdhar | create | |
|