From 6ab1d58c47b06675f1c50fa883bbb09f1b03a1bd Mon Sep 17 00:00:00 2001 From: David-Wobrock Date: Mon, 30 Nov 2020 21:46:40 +0100 Subject: [PATCH] Apply isort to the project --- CHANGELOG.md | 1 + _config.yml | 1 - .../management/commands/lintmigrations.py | 5 ++--- django_migration_linter/migration_linter.py | 10 +++++----- django_migration_linter/sql_analyser/__init__.py | 2 +- setup.cfg | 10 ++++++++++ setup.py | 2 +- tests/functional/test_cache.py | 2 +- .../migrations/0002_a_not_null_field.py | 1 - tests/test_project/app_drop_table/models.py | 1 - .../migrations/0002_make_not_null_with_lib_default.py | 1 - tests/test_project/urls.py | 2 +- tests/unit/test_linter.py | 2 +- tests/unit/test_utils.py | 2 +- tox.ini | 4 +++- 15 files changed, 27 insertions(+), 19 deletions(-) delete mode 100644 _config.yml create mode 100644 setup.cfg diff --git a/CHANGELOG.md b/CHANGELOG.md index 268d540..0de7be4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ Features/fixes: Others: * Switched from Travis CI to GitHub Actions for tests +* Apply `isort` to the project ## 2.4.1 diff --git a/_config.yml b/_config.yml deleted file mode 100644 index c741881..0000000 --- a/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-slate \ No newline at end of file diff --git a/django_migration_linter/management/commands/lintmigrations.py b/django_migration_linter/management/commands/lintmigrations.py index 2c6758d..025a0fb 100644 --- a/django_migration_linter/management/commands/lintmigrations.py +++ b/django_migration_linter/management/commands/lintmigrations.py @@ -5,10 +5,9 @@ from importlib import import_module from django.core.management.base import BaseCommand -from ..utils import register_linting_configuration_options from ...constants import __version__ - -from ...migration_linter import MigrationLinter, MessageType +from ...migration_linter import MessageType, MigrationLinter +from ..utils import register_linting_configuration_options class Command(BaseCommand): diff --git a/django_migration_linter/migration_linter.py b/django_migration_linter/migration_linter.py index 435441a..d77c4a7 100644 --- a/django_migration_linter/migration_linter.py +++ b/django_migration_linter/migration_linter.py @@ -5,24 +5,24 @@ import inspect import logging import os import re -from subprocess import Popen, PIPE +from enum import Enum, unique +from subprocess import PIPE, Popen from django.conf import settings from django.core.management import call_command -from django.db import DEFAULT_DB_ALIAS, connections, ProgrammingError +from django.db import DEFAULT_DB_ALIAS, ProgrammingError, connections from django.db.migrations import RunPython, RunSQL -from enum import Enum, unique from six import PY2 from .cache import Cache from .constants import ( DEFAULT_CACHE_PATH, - EXPECTED_DATA_MIGRATION_ARGS, DJANGO_APPS_WITH_MIGRATIONS, + EXPECTED_DATA_MIGRATION_ARGS, ) -from .utils import clean_bytes_to_str, get_migration_abspath, split_migration_path from .operations import IgnoreMigration from .sql_analyser import analyse_sql_statements +from .utils import clean_bytes_to_str, get_migration_abspath, split_migration_path logger = logging.getLogger(__name__) diff --git a/django_migration_linter/sql_analyser/__init__.py b/django_migration_linter/sql_analyser/__init__.py index 109432f..5493407 100644 --- a/django_migration_linter/sql_analyser/__init__.py +++ b/django_migration_linter/sql_analyser/__init__.py @@ -1,5 +1,5 @@ +from .analyser import analyse_sql_statements # noqa from .base import BaseAnalyser # noqa from .mysql import MySqlAnalyser # noqa from .postgresql import PostgresqlAnalyser # noqa from .sqlite import SqliteAnalyser # noqa -from .analyser import analyse_sql_statements # noqa diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..97dbfa5 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,10 @@ +[flake8] +max-line-length = 88 + +[isort] +multi_line_output = 3 +include_trailing_comma = True +force_grid_wrap = 0 +use_parentheses = True +ensure_newline_before_comments = True +line_length = 88 diff --git a/setup.py b/setup.py index 15881c2..bf4d9bf 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,8 @@ import ast import re from os import path -from setuptools import setup, find_packages +from setuptools import find_packages, setup PROJECT_DIR = path.abspath(path.dirname(__file__)) diff --git a/tests/functional/test_cache.py b/tests/functional/test_cache.py index 4b942f7..3b0d6ef 100644 --- a/tests/functional/test_cache.py +++ b/tests/functional/test_cache.py @@ -6,10 +6,10 @@ from django.conf import settings from django.db.migrations import Migration from django_migration_linter import ( + IgnoreMigration, MigrationLinter, analyse_sql_statements, get_migration_abspath, - IgnoreMigration, ) if sys.version_info >= (3, 3): diff --git a/tests/test_project/app_add_not_null_column_followed_by_default/migrations/0002_a_not_null_field.py b/tests/test_project/app_add_not_null_column_followed_by_default/migrations/0002_a_not_null_field.py index a978263..70ee13c 100644 --- a/tests/test_project/app_add_not_null_column_followed_by_default/migrations/0002_a_not_null_field.py +++ b/tests/test_project/app_add_not_null_column_followed_by_default/migrations/0002_a_not_null_field.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals from django.db import migrations, models - from django_add_default_value import AddDefaultValue diff --git a/tests/test_project/app_drop_table/models.py b/tests/test_project/app_drop_table/models.py index 7f441fe..7e3013c 100644 --- a/tests/test_project/app_drop_table/models.py +++ b/tests/test_project/app_drop_table/models.py @@ -3,6 +3,5 @@ from __future__ import unicode_literals from django.db import models - # class A(models.Model): # field_a = models.IntegerField() diff --git a/tests/test_project/app_make_not_null_with_lib_default/migrations/0002_make_not_null_with_lib_default.py b/tests/test_project/app_make_not_null_with_lib_default/migrations/0002_make_not_null_with_lib_default.py index d8cd75c..35d842f 100644 --- a/tests/test_project/app_make_not_null_with_lib_default/migrations/0002_make_not_null_with_lib_default.py +++ b/tests/test_project/app_make_not_null_with_lib_default/migrations/0002_make_not_null_with_lib_default.py @@ -1,7 +1,6 @@ # Generated by Django 2.2 on 2020-06-20 15:23 from django.db import migrations, models - from django_add_default_value import AddDefaultValue diff --git a/tests/test_project/urls.py b/tests/test_project/urls.py index 71e4b48..fe835d7 100644 --- a/tests/test_project/urls.py +++ b/tests/test_project/urls.py @@ -13,7 +13,7 @@ Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ -from django.contrib import admin from django.conf.urls import url +from django.contrib import admin urlpatterns = [url("admin/", admin.site.urls)] diff --git a/tests/unit/test_linter.py b/tests/unit/test_linter.py index d086fbe..6743c36 100644 --- a/tests/unit/test_linter.py +++ b/tests/unit/test_linter.py @@ -1,5 +1,5 @@ -import unittest import tempfile +import unittest from django.db.migrations import Migration diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index 700b637..2556a47 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -1,6 +1,6 @@ import unittest -from django_migration_linter.utils import split_path, split_migration_path +from django_migration_linter.utils import split_migration_path, split_path class SplitPathTestCase(unittest.TestCase): diff --git a/tox.ini b/tox.ini index aa28ad5..26287d8 100644 --- a/tox.ini +++ b/tox.ini @@ -32,6 +32,8 @@ basepython = python3.6 deps = flake8==3.8.4 black==20.8b1 + isort==5.6.4 commands = - flake8 --max-line-length=88 django_migration_linter + flake8 django_migration_linter/ black --check django_migration_linter/ tests/ manage.py setup.py + isort --check-only .