diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 0000000000..6e90fc79c3 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,9 @@ +[settings] +line_length=119 +known_first_party=leapp +multi_line_output=3 +honor_noqa=true +# NOTE(ivasilev) Ideal solution would be order_by_type with classes exception (for ex. RPM) but this isn't supported +# in 4.3.2 +case_sensitive=false +order_by_type=false diff --git a/Makefile b/Makefile index d0b31d0c99..a804791e2d 100644 --- a/Makefile +++ b/Makefile @@ -106,6 +106,7 @@ help: @echo " install-deps-fedora create python virtualenv and install there" @echo " leapp-repository with dependencies for Fedora OS" @echo " lint lint source code" + @echo " lint_fix attempt to fix isort violations inplace" @echo " test lint source code and run tests" @echo " test_no_lint run tests without linting the source code" @echo "" @@ -260,6 +261,21 @@ lint: echo "--- Linting done. ---"; \ fi + . $(VENVNAME)/bin/activate; \ + git diff $(MASTER_BRANCH) --name-only | xargs isort -c --diff || \ + { \ + echo; \ + echo "------------------------------------------------------------------------------"; \ + echo "Hint: Apply the required changes."; \ + echo " Execute the following command to apply them automatically: make lint_fix"; \ + exit 1; \ + } && echo "--- isort check done. ---"; + +lint_fix: + . $(VENVNAME)/bin/activate; \ + git diff $(MASTER_BRANCH) --name-only | xargs isort && \ + echo "--- isort inplace fixing done. ---;" + test_no_lint: . $(VENVNAME)/bin/activate; \ snactor repo find --path repos/; \ diff --git a/requirements.txt b/requirements.txt index f5c33e947b..051914d5d4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ ### Additional requirements flake8 -flake8-import-order +isort funcsigs==1.0.2 mock==2.0.0 pylint