the idea is based on dataclass' post_init, but the purpose is different.
this is mainly for typing purposes, when subclassing an existing class.
normally when subclassing a class while overriding its init dunder, you need to match the signature of the parent class, if it has overloads it becomes a painful process.
this is especially annoying when you dont actually need the init arguments.
for example:
class a:
@overload
def __init__(self, obj: int) -> None
def __init__(self, obj: str) -> None
def __init__(self, obj):
self.obj = obj
class b:
@overload
def __init__(self, obj: int) -> None
def __init__(self, obj: str) -> None
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.obj_id = id(obj) # or whatever
so, i've created a post_init dunder for this, using a metaclass: