We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Inherited dataclasses don't resolve forward refs
# Bug

```
pydantic version: 1.5.1
python version: 3.8.2
```

a.py:
```py
from __future__ import annotations
from uuid import UUID
from pydantic.dataclasses import dataclass

@dataclass
class A:
    uuid: UUID

    # workaround
    # def __post_init__(self):
    #     self.__pydantic_model__.update_forward_refs(**globals())
```

b.py:
```py
from __future__ import annotations
from uuid import uuid4
from pydantic.dataclasses import dataclass
from a import A

@dataclass
class B(A):
    pass

B(uuid=uuid4())
```

`B(uuid=uuid4())` throws `field "uuid" not yet prepared so type is still a ForwardRef, you might need to call B.update_forward_refs()`.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pydantic/dataclasses.py`
Content:
```
1 from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Type, TypeVar, Union, overload
2 
3 from .class_validators import gather_all_validators
4 from .error_wrappers import ValidationError
5 from .errors import DataclassTypeError
6 from .fields import Required
7 from .main import create_model, validate_model
8 from .utils import ClassAttribute
9 
10 if TYPE_CHECKING:
11     from .main import BaseConfig, BaseModel  # noqa: F401
12     from .typing import CallableGenerator
13 
14     DataclassT = TypeVar('DataclassT', bound='Dataclass')
15 
16     class Dataclass:
17         __pydantic_model__: Type[BaseModel]
18         __initialised__: bool
19         __post_init_original__: Optional[Callable[..., None]]
20         __processed__: Optional[ClassAttribute]
21 
22         def __init__(self, *args: Any, **kwargs: Any) -> None:
23             pass
24 
25         @classmethod
26         def __get_validators__(cls: Type['Dataclass']) -> 'CallableGenerator':
27             pass
28 
29         @classmethod
30         def __validate__(cls: Type['DataclassT'], v: Any) -> 'DataclassT':
31             pass
32 
33         def __call__(self: 'DataclassT', *args: Any, **kwargs: Any) -> 'DataclassT':
34             pass
35 
36 
37 def _validate_dataclass(cls: Type['DataclassT'], v: Any) -> 'DataclassT':
38     if isinstance(v, cls):
39         return v
40     elif isinstance(v, (list, tuple)):
41         return cls(*v)
42     elif isinstance(v, dict):
43         return cls(**v)
44     # In nested dataclasses, v can be of type `dataclasses.dataclass`.
45     # But to validate fields `cls` will be in fact a `pydantic.dataclasses.dataclass`,
46     # which inherits directly from the class of `v`.
47     elif is_builtin_dataclass(v) and cls.__bases__[0] is type(v):
48         import dataclasses
49 
50         return cls(**dataclasses.asdict(v))
51     else:
52         raise DataclassTypeError(class_name=cls.__name__)
53 
54 
55 def _get_validators(cls: Type['Dataclass']) -> 'CallableGenerator':
56     yield cls.__validate__
57 
58 
59 def setattr_validate_assignment(self: 'Dataclass', name: str, value: Any) -> None:
60     if self.__initialised__:
61         d = dict(self.__dict__)
62         d.pop(name, None)
63         known_field = self.__pydantic_model__.__fields__.get(name, None)
64         if known_field:
65             value, error_ = known_field.validate(value, d, loc=name, cls=self.__class__)
66             if error_:
67                 raise ValidationError([error_], self.__class__)
68 
69     object.__setattr__(self, name, value)
70 
71 
72 def is_builtin_dataclass(_cls: Type[Any]) -> bool:
73     """
74     `dataclasses.is_dataclass` is True if one of the class parents is a `dataclass`.
75     This is why we also add a class attribute `__processed__` to only consider 'direct' built-in dataclasses
76     """
77     import dataclasses
78 
79     return not hasattr(_cls, '__processed__') and dataclasses.is_dataclass(_cls)
80 
81 
82 def _process_class(
83     _cls: Type[Any],
84     init: bool,
85     repr: bool,
86     eq: bool,
87     order: bool,
88     unsafe_hash: bool,
89     frozen: bool,
90     config: Optional[Type[Any]],
91 ) -> Type['Dataclass']:
92     import dataclasses
93 
94     post_init_original = getattr(_cls, '__post_init__', None)
95     if post_init_original and post_init_original.__name__ == '_pydantic_post_init':
96         post_init_original = None
97     if not post_init_original:
98         post_init_original = getattr(_cls, '__post_init_original__', None)
99 
100     post_init_post_parse = getattr(_cls, '__post_init_post_parse__', None)
101 
102     def _pydantic_post_init(self: 'Dataclass', *initvars: Any) -> None:
103         if post_init_original is not None:
104             post_init_original(self, *initvars)
105         d, _, validation_error = validate_model(self.__pydantic_model__, self.__dict__, cls=self.__class__)
106         if validation_error:
107             raise validation_error
108         object.__setattr__(self, '__dict__', d)
109         object.__setattr__(self, '__initialised__', True)
110         if post_init_post_parse is not None:
111             post_init_post_parse(self, *initvars)
112 
113     # If the class is already a dataclass, __post_init__ will not be called automatically
114     # so no validation will be added.
115     # We hence create dynamically a new dataclass:
116     # ```
117     # @dataclasses.dataclass
118     # class NewClass(_cls):
119     #   __post_init__ = _pydantic_post_init
120     # ```
121     # with the exact same fields as the base dataclass
122     # and register it on module level to address pickle problem:
123     # https://github.com/samuelcolvin/pydantic/issues/2111
124     if is_builtin_dataclass(_cls):
125         uniq_class_name = f'_Pydantic_{_cls.__name__}_{id(_cls)}'
126         _cls = type(
127             # for pretty output new class will have the name as original
128             _cls.__name__,
129             (_cls,),
130             {
131                 '__annotations__': _cls.__annotations__,
132                 '__post_init__': _pydantic_post_init,
133                 # attrs for pickle to find this class
134                 '__module__': __name__,
135                 '__qualname__': uniq_class_name,
136             },
137         )
138         globals()[uniq_class_name] = _cls
139     else:
140         _cls.__post_init__ = _pydantic_post_init
141     cls: Type['Dataclass'] = dataclasses.dataclass(  # type: ignore
142         _cls, init=init, repr=repr, eq=eq, order=order, unsafe_hash=unsafe_hash, frozen=frozen
143     )
144     cls.__processed__ = ClassAttribute('__processed__', True)
145 
146     fields: Dict[str, Any] = {}
147     for field in dataclasses.fields(cls):
148 
149         if field.default != dataclasses.MISSING:
150             field_value = field.default
151         # mypy issue 7020 and 708
152         elif field.default_factory != dataclasses.MISSING:  # type: ignore
153             field_value = field.default_factory()  # type: ignore
154         else:
155             field_value = Required
156 
157         fields[field.name] = (field.type, field_value)
158 
159     validators = gather_all_validators(cls)
160     cls.__pydantic_model__ = create_model(
161         cls.__name__, __config__=config, __module__=_cls.__module__, __validators__=validators, **fields
162     )
163 
164     cls.__initialised__ = False
165     cls.__validate__ = classmethod(_validate_dataclass)  # type: ignore[assignment]
166     cls.__get_validators__ = classmethod(_get_validators)  # type: ignore[assignment]
167     if post_init_original:
168         cls.__post_init_original__ = post_init_original
169 
170     if cls.__pydantic_model__.__config__.validate_assignment and not frozen:
171         cls.__setattr__ = setattr_validate_assignment  # type: ignore[assignment]
172 
173     return cls
174 
175 
176 @overload
177 def dataclass(
178     *,
179     init: bool = True,
180     repr: bool = True,
181     eq: bool = True,
182     order: bool = False,
183     unsafe_hash: bool = False,
184     frozen: bool = False,
185     config: Type[Any] = None,
186 ) -> Callable[[Type[Any]], Type['Dataclass']]:
187     ...
188 
189 
190 @overload
191 def dataclass(
192     _cls: Type[Any],
193     *,
194     init: bool = True,
195     repr: bool = True,
196     eq: bool = True,
197     order: bool = False,
198     unsafe_hash: bool = False,
199     frozen: bool = False,
200     config: Type[Any] = None,
201 ) -> Type['Dataclass']:
202     ...
203 
204 
205 def dataclass(
206     _cls: Optional[Type[Any]] = None,
207     *,
208     init: bool = True,
209     repr: bool = True,
210     eq: bool = True,
211     order: bool = False,
212     unsafe_hash: bool = False,
213     frozen: bool = False,
214     config: Type[Any] = None,
215 ) -> Union[Callable[[Type[Any]], Type['Dataclass']], Type['Dataclass']]:
216     """
217     Like the python standard lib dataclasses but with type validation.
218 
219     Arguments are the same as for standard dataclasses, except for validate_assignment which has the same meaning
220     as Config.validate_assignment.
221     """
222 
223     def wrap(cls: Type[Any]) -> Type['Dataclass']:
224         return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen, config)
225 
226     if _cls is None:
227         return wrap
228 
229     return wrap(_cls)
230 
231 
232 def make_dataclass_validator(_cls: Type[Any], config: Type['BaseConfig']) -> 'CallableGenerator':
233     """
234     Create a pydantic.dataclass from a builtin dataclass to add type validation
235     and yield the validators
236     It retrieves the parameters of the dataclass and forwards them to the newly created dataclass
237     """
238     dataclass_params = _cls.__dataclass_params__
239     stdlib_dataclass_parameters = {param: getattr(dataclass_params, param) for param in dataclass_params.__slots__}
240     cls = dataclass(_cls, config=config, **stdlib_dataclass_parameters)
241     yield from _get_validators(cls)
242
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pydantic/dataclasses.py b/pydantic/dataclasses.py
--- a/pydantic/dataclasses.py
+++ b/pydantic/dataclasses.py
@@ -5,6 +5,7 @@
 from .errors import DataclassTypeError
 from .fields import Required
 from .main import create_model, validate_model
+from .typing import resolve_annotations
 from .utils import ClassAttribute
 
 if TYPE_CHECKING:
@@ -128,7 +129,7 @@
             _cls.__name__,
             (_cls,),
             {
-                '__annotations__': _cls.__annotations__,
+                '__annotations__': resolve_annotations(_cls.__annotations__, _cls.__module__),
                 '__post_init__': _pydantic_post_init,
                 # attrs for pickle to find this class
                 '__module__': __name__,

{"golden_diff": "diff --git a/pydantic/dataclasses.py b/pydantic/dataclasses.py\n--- a/pydantic/dataclasses.py\n+++ b/pydantic/dataclasses.py\n@@ -5,6 +5,7 @@\n from .errors import DataclassTypeError\n from .fields import Required\n from .main import create_model, validate_model\n+from .typing import resolve_annotations\n from .utils import ClassAttribute\n \n if TYPE_CHECKING:\n@@ -128,7 +129,7 @@\n             _cls.__name__,\n             (_cls,),\n             {\n-                '__annotations__': _cls.__annotations__,\n+                '__annotations__': resolve_annotations(_cls.__annotations__, _cls.__module__),\n                 '__post_init__': _pydantic_post_init,\n                 # attrs for pickle to find this class\n                 '__module__': __name__,\n", "issue": "Inherited dataclasses don't resolve forward refs\n# Bug\r\n\r\n```\r\npydantic version: 1.5.1\r\npython version: 3.8.2\r\n```\r\n\r\na.py:\r\n```py\r\nfrom __future__ import annotations\r\nfrom uuid import UUID\r\nfrom pydantic.dataclasses import dataclass\r\n\r\n@dataclass\r\nclass A:\r\n    uuid: UUID\r\n\r\n    # workaround\r\n    # def __post_init__(self):\r\n    #     self.__pydantic_model__.update_forward_refs(**globals())\r\n```\r\n\r\nb.py:\r\n```py\r\nfrom __future__ import annotations\r\nfrom uuid import uuid4\r\nfrom pydantic.dataclasses import dataclass\r\nfrom a import A\r\n\r\n@dataclass\r\nclass B(A):\r\n    pass\r\n\r\nB(uuid=uuid4())\r\n```\r\n\r\n`B(uuid=uuid4())` throws `field \"uuid\" not yet prepared so type is still a ForwardRef, you might need to call B.update_forward_refs()`.\n", "before_files": [{"content": "from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Type, TypeVar, Union, overload\n\nfrom .class_validators import gather_all_validators\nfrom .error_wrappers import ValidationError\nfrom .errors import DataclassTypeError\nfrom .fields import Required\nfrom .main import create_model, validate_model\nfrom .utils import ClassAttribute\n\nif TYPE_CHECKING:\n    from .main import BaseConfig, BaseModel  # noqa: F401\n    from .typing import CallableGenerator\n\n    DataclassT = TypeVar('DataclassT', bound='Dataclass')\n\n    class Dataclass:\n        __pydantic_model__: Type[BaseModel]\n        __initialised__: bool\n        __post_init_original__: Optional[Callable[..., None]]\n        __processed__: Optional[ClassAttribute]\n\n        def __init__(self, *args: Any, **kwargs: Any) -> None:\n            pass\n\n        @classmethod\n        def __get_validators__(cls: Type['Dataclass']) -> 'CallableGenerator':\n            pass\n\n        @classmethod\n        def __validate__(cls: Type['DataclassT'], v: Any) -> 'DataclassT':\n            pass\n\n        def __call__(self: 'DataclassT', *args: Any, **kwargs: Any) -> 'DataclassT':\n            pass\n\n\ndef _validate_dataclass(cls: Type['DataclassT'], v: Any) -> 'DataclassT':\n    if isinstance(v, cls):\n        return v\n    elif isinstance(v, (list, tuple)):\n        return cls(*v)\n    elif isinstance(v, dict):\n        return cls(**v)\n    # In nested dataclasses, v can be of type `dataclasses.dataclass`.\n    # But to validate fields `cls` will be in fact a `pydantic.dataclasses.dataclass`,\n    # which inherits directly from the class of `v`.\n    elif is_builtin_dataclass(v) and cls.__bases__[0] is type(v):\n        import dataclasses\n\n        return cls(**dataclasses.asdict(v))\n    else:\n        raise DataclassTypeError(class_name=cls.__name__)\n\n\ndef _get_validators(cls: Type['Dataclass']) -> 'CallableGenerator':\n    yield cls.__validate__\n\n\ndef setattr_validate_assignment(self: 'Dataclass', name: str, value: Any) -> None:\n    if self.__initialised__:\n        d = dict(self.__dict__)\n        d.pop(name, None)\n        known_field = self.__pydantic_model__.__fields__.get(name, None)\n        if known_field:\n            value, error_ = known_field.validate(value, d, loc=name, cls=self.__class__)\n            if error_:\n                raise ValidationError([error_], self.__class__)\n\n    object.__setattr__(self, name, value)\n\n\ndef is_builtin_dataclass(_cls: Type[Any]) -> bool:\n    \"\"\"\n    `dataclasses.is_dataclass` is True if one of the class parents is a `dataclass`.\n    This is why we also add a class attribute `__processed__` to only consider 'direct' built-in dataclasses\n    \"\"\"\n    import dataclasses\n\n    return not hasattr(_cls, '__processed__') and dataclasses.is_dataclass(_cls)\n\n\ndef _process_class(\n    _cls: Type[Any],\n    init: bool,\n    repr: bool,\n    eq: bool,\n    order: bool,\n    unsafe_hash: bool,\n    frozen: bool,\n    config: Optional[Type[Any]],\n) -> Type['Dataclass']:\n    import dataclasses\n\n    post_init_original = getattr(_cls, '__post_init__', None)\n    if post_init_original and post_init_original.__name__ == '_pydantic_post_init':\n        post_init_original = None\n    if not post_init_original:\n        post_init_original = getattr(_cls, '__post_init_original__', None)\n\n    post_init_post_parse = getattr(_cls, '__post_init_post_parse__', None)\n\n    def _pydantic_post_init(self: 'Dataclass', *initvars: Any) -> None:\n        if post_init_original is not None:\n            post_init_original(self, *initvars)\n        d, _, validation_error = validate_model(self.__pydantic_model__, self.__dict__, cls=self.__class__)\n        if validation_error:\n            raise validation_error\n        object.__setattr__(self, '__dict__', d)\n        object.__setattr__(self, '__initialised__', True)\n        if post_init_post_parse is not None:\n            post_init_post_parse(self, *initvars)\n\n    # If the class is already a dataclass, __post_init__ will not be called automatically\n    # so no validation will be added.\n    # We hence create dynamically a new dataclass:\n    # ```\n    # @dataclasses.dataclass\n    # class NewClass(_cls):\n    #   __post_init__ = _pydantic_post_init\n    # ```\n    # with the exact same fields as the base dataclass\n    # and register it on module level to address pickle problem:\n    # https://github.com/samuelcolvin/pydantic/issues/2111\n    if is_builtin_dataclass(_cls):\n        uniq_class_name = f'_Pydantic_{_cls.__name__}_{id(_cls)}'\n        _cls = type(\n            # for pretty output new class will have the name as original\n            _cls.__name__,\n            (_cls,),\n            {\n                '__annotations__': _cls.__annotations__,\n                '__post_init__': _pydantic_post_init,\n                # attrs for pickle to find this class\n                '__module__': __name__,\n                '__qualname__': uniq_class_name,\n            },\n        )\n        globals()[uniq_class_name] = _cls\n    else:\n        _cls.__post_init__ = _pydantic_post_init\n    cls: Type['Dataclass'] = dataclasses.dataclass(  # type: ignore\n        _cls, init=init, repr=repr, eq=eq, order=order, unsafe_hash=unsafe_hash, frozen=frozen\n    )\n    cls.__processed__ = ClassAttribute('__processed__', True)\n\n    fields: Dict[str, Any] = {}\n    for field in dataclasses.fields(cls):\n\n        if field.default != dataclasses.MISSING:\n            field_value = field.default\n        # mypy issue 7020 and 708\n        elif field.default_factory != dataclasses.MISSING:  # type: ignore\n            field_value = field.default_factory()  # type: ignore\n        else:\n            field_value = Required\n\n        fields[field.name] = (field.type, field_value)\n\n    validators = gather_all_validators(cls)\n    cls.__pydantic_model__ = create_model(\n        cls.__name__, __config__=config, __module__=_cls.__module__, __validators__=validators, **fields\n    )\n\n    cls.__initialised__ = False\n    cls.__validate__ = classmethod(_validate_dataclass)  # type: ignore[assignment]\n    cls.__get_validators__ = classmethod(_get_validators)  # type: ignore[assignment]\n    if post_init_original:\n        cls.__post_init_original__ = post_init_original\n\n    if cls.__pydantic_model__.__config__.validate_assignment and not frozen:\n        cls.__setattr__ = setattr_validate_assignment  # type: ignore[assignment]\n\n    return cls\n\n\n@overload\ndef dataclass(\n    *,\n    init: bool = True,\n    repr: bool = True,\n    eq: bool = True,\n    order: bool = False,\n    unsafe_hash: bool = False,\n    frozen: bool = False,\n    config: Type[Any] = None,\n) -> Callable[[Type[Any]], Type['Dataclass']]:\n    ...\n\n\n@overload\ndef dataclass(\n    _cls: Type[Any],\n    *,\n    init: bool = True,\n    repr: bool = True,\n    eq: bool = True,\n    order: bool = False,\n    unsafe_hash: bool = False,\n    frozen: bool = False,\n    config: Type[Any] = None,\n) -> Type['Dataclass']:\n    ...\n\n\ndef dataclass(\n    _cls: Optional[Type[Any]] = None,\n    *,\n    init: bool = True,\n    repr: bool = True,\n    eq: bool = True,\n    order: bool = False,\n    unsafe_hash: bool = False,\n    frozen: bool = False,\n    config: Type[Any] = None,\n) -> Union[Callable[[Type[Any]], Type['Dataclass']], Type['Dataclass']]:\n    \"\"\"\n    Like the python standard lib dataclasses but with type validation.\n\n    Arguments are the same as for standard dataclasses, except for validate_assignment which has the same meaning\n    as Config.validate_assignment.\n    \"\"\"\n\n    def wrap(cls: Type[Any]) -> Type['Dataclass']:\n        return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen, config)\n\n    if _cls is None:\n        return wrap\n\n    return wrap(_cls)\n\n\ndef make_dataclass_validator(_cls: Type[Any], config: Type['BaseConfig']) -> 'CallableGenerator':\n    \"\"\"\n    Create a pydantic.dataclass from a builtin dataclass to add type validation\n    and yield the validators\n    It retrieves the parameters of the dataclass and forwards them to the newly created dataclass\n    \"\"\"\n    dataclass_params = _cls.__dataclass_params__\n    stdlib_dataclass_parameters = {param: getattr(dataclass_params, param) for param in dataclass_params.__slots__}\n    cls = dataclass(_cls, config=config, **stdlib_dataclass_parameters)\n    yield from _get_validators(cls)\n", "path": "pydantic/dataclasses.py"}], "after_files": [{"content": "from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Type, TypeVar, Union, overload\n\nfrom .class_validators import gather_all_validators\nfrom .error_wrappers import ValidationError\nfrom .errors import DataclassTypeError\nfrom .fields import Required\nfrom .main import create_model, validate_model\nfrom .typing import resolve_annotations\nfrom .utils import ClassAttribute\n\nif TYPE_CHECKING:\n    from .main import BaseConfig, BaseModel  # noqa: F401\n    from .typing import CallableGenerator\n\n    DataclassT = TypeVar('DataclassT', bound='Dataclass')\n\n    class Dataclass:\n        __pydantic_model__: Type[BaseModel]\n        __initialised__: bool\n        __post_init_original__: Optional[Callable[..., None]]\n        __processed__: Optional[ClassAttribute]\n\n        def __init__(self, *args: Any, **kwargs: Any) -> None:\n            pass\n\n        @classmethod\n        def __get_validators__(cls: Type['Dataclass']) -> 'CallableGenerator':\n            pass\n\n        @classmethod\n        def __validate__(cls: Type['DataclassT'], v: Any) -> 'DataclassT':\n            pass\n\n        def __call__(self: 'DataclassT', *args: Any, **kwargs: Any) -> 'DataclassT':\n            pass\n\n\ndef _validate_dataclass(cls: Type['DataclassT'], v: Any) -> 'DataclassT':\n    if isinstance(v, cls):\n        return v\n    elif isinstance(v, (list, tuple)):\n        return cls(*v)\n    elif isinstance(v, dict):\n        return cls(**v)\n    # In nested dataclasses, v can be of type `dataclasses.dataclass`.\n    # But to validate fields `cls` will be in fact a `pydantic.dataclasses.dataclass`,\n    # which inherits directly from the class of `v`.\n    elif is_builtin_dataclass(v) and cls.__bases__[0] is type(v):\n        import dataclasses\n\n        return cls(**dataclasses.asdict(v))\n    else:\n        raise DataclassTypeError(class_name=cls.__name__)\n\n\ndef _get_validators(cls: Type['Dataclass']) -> 'CallableGenerator':\n    yield cls.__validate__\n\n\ndef setattr_validate_assignment(self: 'Dataclass', name: str, value: Any) -> None:\n    if self.__initialised__:\n        d = dict(self.__dict__)\n        d.pop(name, None)\n        known_field = self.__pydantic_model__.__fields__.get(name, None)\n        if known_field:\n            value, error_ = known_field.validate(value, d, loc=name, cls=self.__class__)\n            if error_:\n                raise ValidationError([error_], self.__class__)\n\n    object.__setattr__(self, name, value)\n\n\ndef is_builtin_dataclass(_cls: Type[Any]) -> bool:\n    \"\"\"\n    `dataclasses.is_dataclass` is True if one of the class parents is a `dataclass`.\n    This is why we also add a class attribute `__processed__` to only consider 'direct' built-in dataclasses\n    \"\"\"\n    import dataclasses\n\n    return not hasattr(_cls, '__processed__') and dataclasses.is_dataclass(_cls)\n\n\ndef _process_class(\n    _cls: Type[Any],\n    init: bool,\n    repr: bool,\n    eq: bool,\n    order: bool,\n    unsafe_hash: bool,\n    frozen: bool,\n    config: Optional[Type[Any]],\n) -> Type['Dataclass']:\n    import dataclasses\n\n    post_init_original = getattr(_cls, '__post_init__', None)\n    if post_init_original and post_init_original.__name__ == '_pydantic_post_init':\n        post_init_original = None\n    if not post_init_original:\n        post_init_original = getattr(_cls, '__post_init_original__', None)\n\n    post_init_post_parse = getattr(_cls, '__post_init_post_parse__', None)\n\n    def _pydantic_post_init(self: 'Dataclass', *initvars: Any) -> None:\n        if post_init_original is not None:\n            post_init_original(self, *initvars)\n        d, _, validation_error = validate_model(self.__pydantic_model__, self.__dict__, cls=self.__class__)\n        if validation_error:\n            raise validation_error\n        object.__setattr__(self, '__dict__', d)\n        object.__setattr__(self, '__initialised__', True)\n        if post_init_post_parse is not None:\n            post_init_post_parse(self, *initvars)\n\n    # If the class is already a dataclass, __post_init__ will not be called automatically\n    # so no validation will be added.\n    # We hence create dynamically a new dataclass:\n    # ```\n    # @dataclasses.dataclass\n    # class NewClass(_cls):\n    #   __post_init__ = _pydantic_post_init\n    # ```\n    # with the exact same fields as the base dataclass\n    # and register it on module level to address pickle problem:\n    # https://github.com/samuelcolvin/pydantic/issues/2111\n    if is_builtin_dataclass(_cls):\n        uniq_class_name = f'_Pydantic_{_cls.__name__}_{id(_cls)}'\n        _cls = type(\n            # for pretty output new class will have the name as original\n            _cls.__name__,\n            (_cls,),\n            {\n                '__annotations__': resolve_annotations(_cls.__annotations__, _cls.__module__),\n                '__post_init__': _pydantic_post_init,\n                # attrs for pickle to find this class\n                '__module__': __name__,\n                '__qualname__': uniq_class_name,\n            },\n        )\n        globals()[uniq_class_name] = _cls\n    else:\n        _cls.__post_init__ = _pydantic_post_init\n    cls: Type['Dataclass'] = dataclasses.dataclass(  # type: ignore\n        _cls, init=init, repr=repr, eq=eq, order=order, unsafe_hash=unsafe_hash, frozen=frozen\n    )\n    cls.__processed__ = ClassAttribute('__processed__', True)\n\n    fields: Dict[str, Any] = {}\n    for field in dataclasses.fields(cls):\n\n        if field.default != dataclasses.MISSING:\n            field_value = field.default\n        # mypy issue 7020 and 708\n        elif field.default_factory != dataclasses.MISSING:  # type: ignore\n            field_value = field.default_factory()  # type: ignore\n        else:\n            field_value = Required\n\n        fields[field.name] = (field.type, field_value)\n\n    validators = gather_all_validators(cls)\n    cls.__pydantic_model__ = create_model(\n        cls.__name__, __config__=config, __module__=_cls.__module__, __validators__=validators, **fields\n    )\n\n    cls.__initialised__ = False\n    cls.__validate__ = classmethod(_validate_dataclass)  # type: ignore[assignment]\n    cls.__get_validators__ = classmethod(_get_validators)  # type: ignore[assignment]\n    if post_init_original:\n        cls.__post_init_original__ = post_init_original\n\n    if cls.__pydantic_model__.__config__.validate_assignment and not frozen:\n        cls.__setattr__ = setattr_validate_assignment  # type: ignore[assignment]\n\n    return cls\n\n\n@overload\ndef dataclass(\n    *,\n    init: bool = True,\n    repr: bool = True,\n    eq: bool = True,\n    order: bool = False,\n    unsafe_hash: bool = False,\n    frozen: bool = False,\n    config: Type[Any] = None,\n) -> Callable[[Type[Any]], Type['Dataclass']]:\n    ...\n\n\n@overload\ndef dataclass(\n    _cls: Type[Any],\n    *,\n    init: bool = True,\n    repr: bool = True,\n    eq: bool = True,\n    order: bool = False,\n    unsafe_hash: bool = False,\n    frozen: bool = False,\n    config: Type[Any] = None,\n) -> Type['Dataclass']:\n    ...\n\n\ndef dataclass(\n    _cls: Optional[Type[Any]] = None,\n    *,\n    init: bool = True,\n    repr: bool = True,\n    eq: bool = True,\n    order: bool = False,\n    unsafe_hash: bool = False,\n    frozen: bool = False,\n    config: Type[Any] = None,\n) -> Union[Callable[[Type[Any]], Type['Dataclass']], Type['Dataclass']]:\n    \"\"\"\n    Like the python standard lib dataclasses but with type validation.\n\n    Arguments are the same as for standard dataclasses, except for validate_assignment which has the same meaning\n    as Config.validate_assignment.\n    \"\"\"\n\n    def wrap(cls: Type[Any]) -> Type['Dataclass']:\n        return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen, config)\n\n    if _cls is None:\n        return wrap\n\n    return wrap(_cls)\n\n\ndef make_dataclass_validator(_cls: Type[Any], config: Type['BaseConfig']) -> 'CallableGenerator':\n    \"\"\"\n    Create a pydantic.dataclass from a builtin dataclass to add type validation\n    and yield the validators\n    It retrieves the parameters of the dataclass and forwards them to the newly created dataclass\n    \"\"\"\n    dataclass_params = _cls.__dataclass_params__\n    stdlib_dataclass_parameters = {param: getattr(dataclass_params, param) for param in dataclass_params.__slots__}\n    cls = dataclass(_cls, config=config, **stdlib_dataclass_parameters)\n    yield from _get_validators(cls)\n", "path": "pydantic/dataclasses.py"}]}