ericvsmith / dataclasses

Apache License 2.0
587 stars 53 forks source link

When the method __post_init__ doesnt called? #172

Closed Maksim-Burtsev closed 2 years ago

Maksim-Burtsev commented 2 years ago

I found the issue where was conversation about an explict call of parent's __post_init__ method using super(), but if i try this:

from dataclasses import dataclass

@dataclass
class A:
    def __post_init__(self):
        print("A")

@dataclass
class B(A):
    pass

b = B()

it will output:

>> A

So, parents method works without explict call.

  1. I don't understand what talk about was in this issue or problem with inheritence was solved?
  2. In which case __post_init__ method of dataclass doesnt called?
ericvsmith commented 2 years ago

This repository is only for the 3.6 backport of dataclasses. For actual bugs in the current version dataclasses, please use the main python bug tracker. But this sounds more like a usage question, which you could ask on discuss.python.org or stackoverflow.

Maksim-Burtsev commented 2 years ago

This repository is only for the 3.6 backport of dataclasses. For actual bugs in the current version dataclasses, please use the main python bug tracker. But this sounds more like a usage question, which you could ask on discuss.python.org or stackoverflow.

I got it, thanks!