Repository: pydantic/pydantic

Issue:
tests failing on 3.8
Two tests are failing [with python 3.8 on CI](https://travis-ci.org/samuelcolvin/pydantic/jobs/596131963):
* `test_initvars_post_init`
* `test_initvars_post_init_post_parse`

We should fix this since 3.8 is close to release. Any help would be much appreciated, I'll looked quickly but can't quite seem what's wrong.

traceback:

```
―――――――――――――――――――――― test_initvars_post_init_post_parse ――――――――――――――――――――――
    def test_initvars_post_init_post_parse():
        @pydantic.dataclasses.dataclass
>       class PathDataPostInitPostParse:
tests/test_dataclasses.py:504: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
pydantic/dataclasses.py:137: in dataclass
    return wrap(_cls)
pydantic/dataclasses.py:132: in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen, config)
pydantic/dataclasses.py:84: in _process_class
    cls = dataclasses._process_class(_cls, init, repr, eq, order, unsafe_hash, frozen)  # type: ignore
/opt/python/3.8-dev/lib/python3.8/dataclasses.py:967: in _process_class
    str(inspect.signature(cls)).replace(' -> None', ''))
/opt/python/3.8-dev/lib/python3.8/inspect.py:3050: in __str__
    formatted = str(param)
/opt/python/3.8-dev/lib/python3.8/inspect.py:2568: in __str__
    formatannotation(self._annotation))
/opt/python/3.8-dev/lib/python3.8/inspect.py:1202: in formatannotation
    return repr(annotation)
/opt/python/3.8-dev/lib/python3.8/dataclasses.py:213: in __repr__
    return f'dataclasses.InitVar[{self.type.__name__}]'
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = typing.Union[pathlib.Path, NoneType], attr = '__name__'
    def __getattr__(self, attr):
        # We are careful for copy and pickle.
        # Also for simplicity we just don't relay all dunder names
        if '__origin__' in self.__dict__ and not _is_dunder(attr):
            return getattr(self.__origin__, attr)
>       raise AttributeError(attr)
E       AttributeError: __name__
/opt/python/3.8-dev/lib/python3.8/typing.py:757: AttributeError
```


Discussion:
I gusses this is a bug on python3.8 rc1.
It's happened error when we call `repr()` with `InitVar` include `Optional`
python3.8 --version
Python 3.8.0rc1
```pyhton
from dataclasses import InitVar
from typing import Optional

print(repr(InitVar[str]))   # no error 
# > 'dataclasses.InitVar[str]'


print(repr(InitVar[Optional[str]]))  # error
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/dataclasses.py", line 213, in __repr__
    return f'dataclasses.InitVar[{self.type.__name__}]'
  File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/typing.py", line 757, in __getattr__
    raise AttributeError(attr)
AttributeError: __name__
```

PR:
https://github.com/python/cpython/commit/01ee12ba35a333e8a6a25c4153c4a21838e9585c

changelog:
https://docs.python.org/3.8/whatsnew/changelog.html#python-3-8-0-release-candidate-1

yes, I just created [an issue](https://bugs.python.org/issue38431?@ok_message=msg%20354388%20created%0Aissue%2038431%20created&@template=item).

Working on a fix now.
Great work!!
It was too late to watch the code 🤣 

Resolving patch:
diff --git a/pydantic/main.py b/pydantic/main.py
--- a/pydantic/main.py
+++ b/pydantic/main.py
@@ -145,7 +145,7 @@ def validate_custom_root_type(fields: Dict[str, ModelField]) -> None:
 
 class ModelMetaclass(ABCMeta):
     @no_type_check  # noqa C901
-    def __new__(mcs, name, bases, namespace, **kwargs):
+    def __new__(mcs, name, bases, namespace, **kwargs):  # noqa C901
         fields: Dict[str, ModelField] = {}
         config = BaseConfig
         validators: 'ValidatorListDict' = {}


Test patch:
diff --git a/tests/test_validators.py b/tests/test_validators.py
--- a/tests/test_validators.py
+++ b/tests/test_validators.py
@@ -815,7 +815,7 @@ def root_validator_repeated(cls, values):
                 return values
 
             @root_validator  # noqa: F811
-            def root_validator_repeated(cls, values):
+            def root_validator_repeated(cls, values):  # noqa: F811
                 return values
 
 
@@ -830,7 +830,7 @@ def repeat_validator(cls, v):
                 return v
 
             @root_validator(pre=True)  # noqa: F811
-            def repeat_validator(cls, values):
+            def repeat_validator(cls, values):  # noqa: F811
                 return values