Repository: pydantic/pydantic

Issue:
isort 4.3.9 breaks imports in pydantic/__init__.py after monthly update by pyup
<!-- Questions, Feature Requests, and Bug Reports are all welcome -->
<!-- delete as applicable: -->
# Question | Feature Request | Bug

For bugs/questions:
* OS: GNU/Linux (Ubuntu 18.04)
* Python version `import sys; print(sys.version)`: 3.7.2
* Pydantic version `import pydantic; print(pydantic.VERSION)`: 0.21.1 (in development)

It seems that ``isort`` upgrade from 4.3.4 to 4.3.9 in #410 has broken ``make format``. The new version of ``isort`` according to 4.3.6 Changelong:

> ``__init__.py`` has been removed from the default ignore list. The default ignore list is now empty - with all items needing to be explicitly ignored.

``isort`` also ignores an ignore comment ``flake8: noqa``/

So ``make format`` reorders ``pydantic/__init__.py`` this way:

```
diff --git a/pydantic/__init__.py b/pydantic/__init__.py
index d4165ce..67cd874 100644
--- a/pydantic/__init__.py
+++ b/pydantic/__init__.py
@@ -1,4 +1,5 @@
 # flake8: noqa
+from . import dataclasses
 from .class_validators import validator
 from .env_settings import BaseSettings
 from .error_wrappers import ValidationError
@@ -6,7 +7,6 @@ from .errors import *
 from .fields import Required
 from .main import BaseConfig, BaseModel, Extra, create_model, validate_model
 from .parse import Protocol
+from .schema import Schema
 from .types import *
 from .version import VERSION
-from . import dataclasses
-from .schema import Schema
```

That makes ``ValidationError`` unimportable:

```
In [1]: from pydantic import ValidationError                                                                                                                                                                
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-9e2cfd39d904> in <module>
----> 1 from pydantic import ValidationError

~/git/pydantic/pydantic/__init__.py in <module>
      1 # flake8: noqa
----> 2 from . import dataclasses
      3 from .class_validators import validator
      4 from .env_settings import BaseSettings
      5 from .error_wrappers import ValidationError

~/git/pydantic/pydantic/dataclasses.py in <module>
      2 from typing import TYPE_CHECKING, Any, Callable, Dict, Generator, Optional, Type, Union
      3 
----> 4 from . import ValidationError, errors
      5 from .main import create_model, validate_model
      6 from .utils import AnyType

ImportError: cannot import name 'ValidationError' from 'pydantic' (/home/vitaly/git/pydantic/pydantic/__init__.py)
```

Also, it naturally make almost all tests to fail.


My suggestion is that ``isort`` section in ``setup.cfg`` should include something like this:

```
skip=pydantic/__init__.py
```




Discussion:
I wonder if it's just me, or for some reason Travis CI doesn't reproduce this problem?

Resolving patch:
diff --git a/pydantic/__init__.py b/pydantic/__init__.py
--- a/pydantic/__init__.py
+++ b/pydantic/__init__.py
@@ -1,4 +1,5 @@
 # flake8: noqa
+from . import dataclasses
 from .class_validators import validator
 from .env_settings import BaseSettings
 from .error_wrappers import ValidationError
@@ -6,7 +7,6 @@
 from .fields import Required
 from .main import BaseConfig, BaseModel, Extra, create_model, validate_model
 from .parse import Protocol
+from .schema import Schema
 from .types import *
 from .version import VERSION
-from . import dataclasses
-from .schema import Schema
diff --git a/pydantic/dataclasses.py b/pydantic/dataclasses.py
--- a/pydantic/dataclasses.py
+++ b/pydantic/dataclasses.py
@@ -1,7 +1,8 @@
 import dataclasses
 from typing import TYPE_CHECKING, Any, Callable, Dict, Generator, Optional, Type, Union
 
-from . import ValidationError, errors
+from .error_wrappers import ValidationError
+from .errors import DataclassTypeError
 from .main import create_model, validate_model
 from .utils import AnyType
 
@@ -37,7 +38,7 @@ def _validate_dataclass(cls: Type['DataclassType'], v: Any) -> 'DataclassType':
     elif isinstance(v, dict):
         return cls(**v)
     else:
-        raise errors.DataclassTypeError(class_name=cls.__name__)
+        raise DataclassTypeError(class_name=cls.__name__)
 
 
 def _get_validators(cls: Type['DataclassType']) -> Generator[Any, None, None]:


Test patch: