From 3fe42458c07ba144ad7257e70aa022f60374c030 Mon Sep 17 00:00:00 2001 From: Dominik George <dominik.george@teckids.org> Date: Fri, 13 Dec 2019 01:07:26 +0100 Subject: [PATCH] [Tests] Add isort to lint --- .gitlab-ci.yml | 2 +- poetry.lock | 73 +++++++++++++++++++++++++++++++++++++++++--------- pyproject.toml | 2 ++ tox.ini | 18 ++++++++++--- 4 files changed, 77 insertions(+), 18 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 91e29bf95..5318c9d9f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,7 +31,7 @@ test: lint: stage: test script: - - tox -e black,lint,security + - tox -e lint,security allow_failure: true build_dist: diff --git a/poetry.lock b/poetry.lock index 5fb19c4e6..725eb03ca 100644 --- a/poetry.lock +++ b/poetry.lock @@ -515,18 +515,6 @@ django-phonenumber-field = ">=1.1.0,<4.99" django_otp = ">=0.6.0,<0.99" qrcode = ">=4.0.0,<6.99" -[package.dependencies.django-otp-yubikey] -optional = true -version = "*" - -[package.dependencies.phonenumbers] -optional = true -version = ">=7.0.9,<8.99" - -[package.dependencies.twilio] -optional = true -version = ">=6.0" - [package.extras] Call = ["twilio (>=6.0)"] SMS = ["twilio (>=6.0)"] @@ -538,6 +526,7 @@ phonenumberslite = ["phonenumberslite (>=7.0.9,<8.99)"] reference = "fceecb23a60cfd23398cf58f29148be644853697" type = "git" url = "https://github.com/Natureshadow/django-two-factor-auth" + [[package]] category = "main" description = "Integrate django with yarnpkg" @@ -728,6 +717,25 @@ optional = false python-versions = "*" version = "1.1.1" +[[package]] +category = "dev" +description = "flake8 plugin that integrates isort ." +name = "flake8-isort" +optional = false +python-versions = "*" +version = "2.8.0" + +[package.dependencies] +flake8 = ">=3.2.1" +testfixtures = "*" + +[package.dependencies.isort] +extras = ["pyproject"] +version = ">=4.3.0" + +[package.extras] +test = ["pytest"] + [[package]] category = "dev" description = "A plugin for flake8 integrating mypy." @@ -818,6 +826,20 @@ zipp = ">=0.5" docs = ["sphinx", "rst.linker"] testing = ["packaging", "importlib-resources"] +[[package]] +category = "dev" +description = "A Python utility / library to sort Python imports." +name = "isort" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" +version = "4.3.21" + +[package.extras] +pipfile = ["pipreqs", "requirementslib"] +pyproject = ["toml"] +requirements = ["pipreqs", "pip-api"] +xdg_home = ["appdirs (>=1.4.0)"] + [[package]] category = "dev" description = "A very fast and expressive template engine." @@ -1446,6 +1468,19 @@ version = "1.31.0" pbr = ">=2.0.0,<2.1.0 || >2.1.0" six = ">=1.10.0" +[[package]] +category = "dev" +description = "A collection of helpers and mock objects for unit tests and doc tests." +name = "testfixtures" +optional = false +python-versions = "*" +version = "6.10.3" + +[package.extras] +build = ["setuptools-git", "wheel", "twine"] +docs = ["sphinx"] +test = ["pytest (>=3.6)", "pytest-cov", "pytest-django", "sybil", "zope.component", "twisted", "mock", "django (<2)", "django"] + [[package]] category = "dev" description = "utilities for testing.* packages" @@ -1585,7 +1620,7 @@ testing = ["pathlib2", "contextlib2", "unittest2"] ldap = ["django-auth-ldap"] [metadata] -content-hash = "5d1076f710fd2709c08d81f0d2a746de7d9609050a23c4c993d2e5caef284a0d" +content-hash = "be171a75e940a08dd4c63d1d7be5615b9cb23d844f6fe7b3e74a63d2871ae761" python-versions = "^3.7" [metadata.files] @@ -1839,6 +1874,10 @@ flake8-fixme = [ {file = "flake8-fixme-1.1.1.tar.gz", hash = "sha256:50cade07d27a4c30d4f12351478df87339e67640c83041b664724bda6d16f33a"}, {file = "flake8_fixme-1.1.1-py2.py3-none-any.whl", hash = "sha256:226a6f2ef916730899f29ac140bed5d4a17e5aba79f00a0e3ae1eff1997cb1ac"}, ] +flake8-isort = [ + {file = "flake8-isort-2.8.0.tar.gz", hash = "sha256:64454d1f154a303cfe23ee715aca37271d4f1d299b2f2663f45b73bff14e36a9"}, + {file = "flake8_isort-2.8.0-py2.py3-none-any.whl", hash = "sha256:aa0c4d004e6be47e74f122f5b7f36554d0d78ad8bf99b497a460dedccaa7cce9"}, +] flake8-mypy = [ {file = "flake8-mypy-17.8.0.tar.gz", hash = "sha256:47120db63aff631ee1f84bac6fe8e64731dc66da3efc1c51f85e15ade4a3ba18"}, {file = "flake8_mypy-17.8.0-py35.py36-none-any.whl", hash = "sha256:cff009f4250e8391bf48990093cff85802778c345c8449d6498b62efefeebcbc"}, @@ -1870,6 +1909,10 @@ importlib-metadata = [ {file = "importlib_metadata-1.3.0-py2.py3-none-any.whl", hash = "sha256:d95141fbfa7ef2ec65cfd945e2af7e5a6ddbd7c8d9a25e66ff3be8e3daf9f60f"}, {file = "importlib_metadata-1.3.0.tar.gz", hash = "sha256:073a852570f92da5f744a3472af1b61e28e9f78ccf0c9117658dc32b15de7b45"}, ] +isort = [ + {file = "isort-4.3.21-py2.py3-none-any.whl", hash = "sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd"}, + {file = "isort-4.3.21.tar.gz", hash = "sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1"}, +] jinja2 = [ {file = "Jinja2-2.10.3-py2.py3-none-any.whl", hash = "sha256:74320bb91f31270f9551d46522e33af46a80c3d619f4a4bf42b3164d30b5911f"}, {file = "Jinja2-2.10.3.tar.gz", hash = "sha256:9fe95f19286cfefaa917656583d020be14e7859c6b0252588391e47db34527de"}, @@ -2256,6 +2299,10 @@ stevedore = [ {file = "stevedore-1.31.0-py2.py3-none-any.whl", hash = "sha256:01d9f4beecf0fbd070ddb18e5efb10567801ba7ef3ddab0074f54e3cd4e91730"}, {file = "stevedore-1.31.0.tar.gz", hash = "sha256:e0739f9739a681c7a1fda76a102b65295e96a144ccdb552f2ae03c5f0abe8a14"}, ] +testfixtures = [ + {file = "testfixtures-6.10.3-py2.py3-none-any.whl", hash = "sha256:9334f64d4210b734d04abff516d6ddaab7328306a0c4c1268ce4624df51c4f6d"}, + {file = "testfixtures-6.10.3.tar.gz", hash = "sha256:8f22100d4fb841b958f64e71c8820a32dc46f57d4d7e077777b932acd87b7327"}, +] "testing.common.database" = [ {file = "testing.common.database-2.0.3-py2.py3-none-any.whl", hash = "sha256:e3ed492bf480a87f271f74c53b262caf5d85c8bc09989a8f534fa2283ec52492"}, {file = "testing.common.database-2.0.3.tar.gz", hash = "sha256:965d80b2985315325dc358c3061b174a712f4d4d5bf6a80b58b11f9a1dd86d73"}, diff --git a/pyproject.toml b/pyproject.toml index 5c29094f5..acbf2764d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -77,6 +77,8 @@ flake8-docstrings = "^1.5.0" flake8-rst-docstrings = "^0.0.12" black = "^19.10b0" flake8-black = "^0.1.1" +isort = "^4.3.21" +flake8-isort = "^2.8.0" [tool.black] line-length = 100 diff --git a/tox.ini b/tox.ini index 0360454dc..f83b60c70 100644 --- a/tox.ini +++ b/tox.ini @@ -21,7 +21,10 @@ passenv = TEST_HOST [testenv:lint] -commands = poetry run flake8 {posargs} biscuit/core/ +commands = + - poetry run black --check --diff biscuit/core/ + - poetry run isort -c --diff --stdout -rc biscuit/core/ + poetry run flake8 {posargs} biscuit/core/ [testenv:security] commands = poetry run safety check --full-report @@ -33,14 +36,21 @@ commands = poetry build [testenv:docs] commands = poetry run make -C docs/ html {posargs} -[testenv:black] -commands = poetry run black --check --diff biscuit/core/ - [flake8] max_line_length = 100 exclude = migrations,tests ignore = E231 +[isort] +line_length = 100 +balanced = 1 +trailing_comma = 1 +use_parantheses = 1 +default_section = THIRDPARTY +known_first_party = biscuit +known_django = django +sections = FUTURE,STDLIB,DJANGO,THIRDPARTY,FIRSTPARTY,LOCALFOLDER + [mypy] plugins = mypy_django_plugin.main python_version = 3.8 -- GitLab