This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author NeilGirdhar
Recipients NeilGirdhar, eric.smith, sobolevn, veky
Date 2022-02-20.14:48:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1645368488.65.0.17304007841.issue46757@roundup.psfhosted.org>
In-reply-to
Content
> 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
History
Date User Action Args
2022-02-20 14:48:08NeilGirdharsetrecipients: + NeilGirdhar, eric.smith, veky, sobolevn
2022-02-20 14:48:08NeilGirdharsetmessageid: <1645368488.65.0.17304007841.issue46757@roundup.psfhosted.org>
2022-02-20 14:48:08NeilGirdharlinkissue46757 messages
2022-02-20 14:48:08NeilGirdharcreate