Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update isort and black #251

Merged
merged 7 commits into from Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions datamodel_code_generator/format.py
Expand Up @@ -4,7 +4,7 @@

import black
import toml
from isort import SortImports
import isort


class PythonVersion(Enum):
Expand Down Expand Up @@ -49,4 +49,7 @@ def apply_black(code: str, python_version: PythonVersion) -> str:


def apply_isort(code: str) -> str:
return SortImports(file_contents=code).output
if isort.__version__.startswith('4.'):
return isort.SortImports(file_contents=code).output
else:
return isort.code(code)
11 changes: 10 additions & 1 deletion scripts/lint.sh
Expand Up @@ -2,6 +2,15 @@

set -e

python -m venv lint
source lint/bin/activate

pip install black==19.10b0 "isort>=4.3.21,<5.0"

black --check datamodel_code_generator tests
isort --recursive --check-only datamodel_code_generator tests
isort --check-only datamodel_code_generator tests

deactivate
rm -r lint

mypy datamodel_code_generator
13 changes: 12 additions & 1 deletion scripts/test.bat
@@ -1 +1,12 @@
pytest --cov=datamodel_code_generator --cov-report term-missing tests
python -m venv venv

venv\Scripts\activate.bat

pip install -e .[all] isort==4.3.21 "black>=19.10b0,<20"

pytest --cov=datamodel_code_generator --cov-report term-missing tests

deactivate.bat

del /f /s /q venv 1>nul
rmdir /s /q venv
10 changes: 9 additions & 1 deletion scripts/test.sh
@@ -1,4 +1,12 @@
#!/usr/bin/env bash
set -e

pytest --cov=datamodel_code_generator --cov-report term-missing tests
python -m venv venv

source venv/bin/activate
pip install -e .[all] isort==4.3.21 "black>=19.10b0,<20"

pytest --cov=datamodel_code_generator --cov-report term-missing tests

deactivate
rm -r venv
2 changes: 1 addition & 1 deletion setup.cfg
Expand Up @@ -33,7 +33,7 @@ install_requires =
inflect>=4.1.0,<5.0
pydantic[email]>=1.5.1,<2.0
black>=19.10b0,<20
isort>=4.3.21,<5.0
isort>=4.3.21,<6.0
PySnooper>=0.4.1,<1.0.0
toml>=0.10.0,<1.0.0
genson>=1.2.1,<2.0
Expand Down