Skip to content

Commit

Permalink
Add isort check for changed files
Browse files Browse the repository at this point in the history
After discussing with pstodulk a massive change introducing isort
rules and fixing all occurrencies may be too annoying, so let's
make it gradually - intoduce a handmade isort check for changed files
only.
This patch also introduces a lint_fix target that can do fix the order
inplace automatically.
  • Loading branch information
fernflower authored and pirat89 committed Dec 2, 2021
1 parent 2f13fbe commit 2c73622
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down Expand Up @@ -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/; \
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
### Additional requirements

flake8
flake8-import-order
isort
funcsigs==1.0.2
mock==2.0.0
pylint
Expand Down

0 comments on commit 2c73622

Please sign in to comment.