Repository: pydantic/pydantic

Issue:
Сreating a child model causes a RecursionError exception
<!-- Questions, Feature Requests, and Bug Reports are all welcome -->
<!-- delete as applicable: -->
# Bug

* OS: **Ubuntu 14.04**
* Python version `import sys; print(sys.version)`: **3.6.7**
* Pydantic version `import pydantic; print(pydantic.VERSION)`: **0.14**

I'm expecting, that I can use a classic inheritance for dataclass models:
```py
import pydantic.dataclasses

@pydantic.dataclasses.dataclass
class A:
    a: str = None

@pydantic.dataclasses.dataclass
class B(A):
    b: str = None

B(a='a', b='b')
```

But as a result I'm receiving this:
```
Traceback (most recent call last):
  File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 2881, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-9-10a7116ca691>", line 12, in <module>
    B(a='a', b='b')
  File "<string>", line 4, in __init__
  File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/dataclasses.py", line 13, in post_init
    self.__post_init_original__()
  File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/dataclasses.py", line 13, in post_init
    self.__post_init_original__()
  File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/dataclasses.py", line 13, in post_init
    self.__post_init_original__()
  [Previous line repeated 952 more times]
  File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/dataclasses.py", line 9, in post_init
    d = validate_model(self.__pydantic_model__, self.__dict__)
  File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/main.py", line 484, in validate_model
    v_, errors_ = field.validate(value, values, loc=field.alias, cls=model.__class__)
  File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/fields.py", line 303, in validate
    v, errors = self._validate_singleton(v, values, loc, cls)
  File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/fields.py", line 406, in _validate_singleton
    return self._apply_validators(v, values, loc, cls, self.validators)
  File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/fields.py", line 412, in _apply_validators
    v = validator(v)
  File "/usr/local/pyenv/versions/3.6.7/lib/python3.6/site-packages/pydantic/validators.py", line 23, in str_validator
    if isinstance(v, (str, NoneType)):
RecursionError: maximum recursion depth exceeded in __instancecheck__
```
This line below causes this problem:
https://github.com/samuelcolvin/pydantic/blob/master/pydantic/dataclasses.py#L13

UPD: defining `__post_init__` in child model fixes the problem, but this is workaround.
```py
import pydantic.dataclasses

@pydantic.dataclasses.dataclass
class A:
    a: str = None

@pydantic.dataclasses.dataclass
class B(A):
    b: str = None

    def __post_init__():
        pass

B(a='a', b='b')
```


Discussion:
thanks for reporting, I'll try and fix soon.

Resolving patch:
diff --git a/pydantic/dataclasses.py b/pydantic/dataclasses.py
--- a/pydantic/dataclasses.py
+++ b/pydantic/dataclasses.py
@@ -5,7 +5,7 @@
 from .main import create_model, validate_model
 
 
-def post_init(self):
+def _pydantic_post_init(self):
     d = validate_model(self.__pydantic_model__, self.__dict__)
     object.__setattr__(self, '__dict__', d)
     object.__setattr__(self, '__initialised__', True)
@@ -26,7 +26,9 @@ def setattr_validate_assignment(self, name, value):
 
 def _process_class(_cls, init, repr, eq, order, unsafe_hash, frozen, validate_assignment):
     post_init_original = getattr(_cls, '__post_init__', None)
-    _cls.__post_init__ = post_init
+    if post_init_original and post_init_original.__name__ == '_pydantic_post_init':
+        post_init_original = None
+    _cls.__post_init__ = _pydantic_post_init
     cls = dataclasses._process_class(_cls, init, repr, eq, order, unsafe_hash, frozen)
 
     fields = {name: (field.type, field.default) for name, field in cls.__dataclass_fields__.items()}


Test patch:
diff --git a/tests/test_dataclasses.py b/tests/test_dataclasses.py
--- a/tests/test_dataclasses.py
+++ b/tests/test_dataclasses.py
@@ -96,3 +96,20 @@ def __post_init__(self):
     d = MyDataclass('1')
     assert d.a == 1
     assert post_init_called
+
+
+def test_inheritance():
+    @pydantic.dataclasses.dataclass
+    class A:
+        a: str = None
+
+    @pydantic.dataclasses.dataclass
+    class B(A):
+        b: int = None
+
+    b = B(a='a', b=12)
+    assert b.a == 'a'
+    assert b.b == 12
+
+    with pytest.raises(ValidationError):
+        B(a='a', b='b')