Repository: pydantic/pydantic

Issue:
__post_init__ is not triggered for descendant dataclass 
The `__post_init__` method of parent is not called in child classes.

* OS: **Ubuntu**
* Python version `import sys; print(sys.version)`: **3.7.2 (default, Mar 25 2019, 19:29:53) **
* Pydantic version `import pydantic; print(pydantic.VERSION)`: **0.32.1**


```py
from dataclasses import dataclass, field
from typing import Any

# comment the pydantinc import below to see the expected result
from pydantic.dataclasses import dataclass

@dataclass
class Base:
    x: float
    y: float

    def __post_init__(self):
        print('Called!')
        self.z = self.x + self.y

@dataclass
class Child(Base):
    a: int

obj = Child(a=0, x=1.5, y=2.5)
print(obj.z)
```

Everything works fine when using the `dataclass` from standard library. After looking through the code I expected that an easy workaround would be to add simple `__post_init__` in child:

```python
@dataclass
class Child(Base):
    a: int

    def __post_init__(self):
        super().__post_init__()
```

Now I do get 'Called!' message, but the 'z' attribute is not preserved anyway...

Do I miss something obvious in the usage of pydantic?


Comments:
Update: after adding missing `z: float = field(init=False)` in the `Base` class the z attribute is properly preserved (does not get lost between the `__post_init__` and instance completion). But the first issue - `__post_init__` not being called in the first place still stands.

Patch:
diff --git a/pydantic/dataclasses.py b/pydantic/dataclasses.py
--- a/pydantic/dataclasses.py
+++ b/pydantic/dataclasses.py
@@ -62,9 +62,12 @@ def _process_class(
     config: Type['BaseConfig'],
 ) -> 'DataclassType':
     post_init_original = getattr(_cls, '__post_init__', None)
-    post_init_post_parse = getattr(_cls, '__post_init_post_parse__', None)
     if post_init_original and post_init_original.__name__ == '_pydantic_post_init':
         post_init_original = None
+    if not post_init_original:
+        post_init_original = getattr(_cls, '__post_init_original__', None)
+
+    post_init_post_parse = getattr(_cls, '__post_init_post_parse__', None)
 
     def _pydantic_post_init(self: 'DataclassType', *initvars: Any) -> None:
         if post_init_original is not None:
@@ -91,6 +94,8 @@ def _pydantic_post_init(self: 'DataclassType', *initvars: Any) -> None:
     cls.__initialised__ = False
     cls.__validate__ = classmethod(_validate_dataclass)
     cls.__get_validators__ = classmethod(_get_validators)
+    if post_init_original:
+        cls.__post_init_original__ = post_init_original
 
     if cls.__pydantic_model__.__config__.validate_assignment and not frozen:
         cls.__setattr__ = setattr_validate_assignment


Test patch:
diff --git a/tests/test_dataclasses.py b/tests/test_dataclasses.py
--- a/tests/test_dataclasses.py
+++ b/tests/test_dataclasses.py
@@ -486,3 +486,22 @@ class TestClassVar:
 
     tcv = TestClassVar(2)
     assert tcv.klassvar == "I'm a Class variable"
+
+
+def test_inheritance_post_init():
+    post_init_called = False
+
+    @pydantic.dataclasses.dataclass
+    class Base:
+        a: int
+
+        def __post_init__(self):
+            nonlocal post_init_called
+            post_init_called = True
+
+    @pydantic.dataclasses.dataclass
+    class Child(Base):
+        b: int
+
+    Child(a=1, b=2)
+    assert post_init_called