Skip to content

Commit

Permalink
Add Black
Browse files Browse the repository at this point in the history
- Set up CI to run black
- Add makefile task to fix black formatting
- Ensure isort and flake8 config intergrates well
  • Loading branch information
henrikhorluck committed Oct 16, 2019
1 parent 07a410a commit 49c759e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ steps:
- push
group: testing
commands:
- tox -e flake8 -e isort --recreate
- tox -e flake8 -e isort -e black --recreate

- name: python-tests
image: registry.online.ntnu.no/dotkom/onlineweb4-testbase:3.7
Expand Down
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ lint-only: lint-backend lint-frontend
test-only: test-backend test-frontend

lint-backend:
@docker-compose run --rm $(BACKEND_SERVICE_NAME) tox --recreate -e flake8 -e isort
@docker-compose run --rm $(BACKEND_SERVICE_NAME) tox --recreate -e flake8 -e isort -e black

lint-frontend:
@docker-compose run --rm $(FRONTEND_SERVICE_NAME) npm run lint
Expand All @@ -75,3 +75,5 @@ test-backend:
test-frontend:
@docker-compose run --rm $(FRONTEND_SERVICE_NAME) npm run test

lint-backend-fix:
@docker-compose run --rm $(BACKEND_SERVICE_NAME) bash -c "isort -rc apps middleware scripts utils && black apps middleware scripts utils"
1 change: 1 addition & 0 deletions requirements-linting.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
flake8==3.7.8
isort==4.3.21
pycodestyle==2.5
black==19.3b0
10 changes: 7 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
[flake8]
max_line_length = 120
max_line_length = 88
max-complexity = 10
exclude = apps/*/migrations/*
ignore=E203, E501, W503, F401

[isort]
line_length=100
line_length=88
skip=.tox,onlineweb4/settings/__init__.py,migrations
default_section=THIRDPARTY
known_first_party=apps,utils
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
use_parentheses=True

[tool:pytest]
DJANGO_SETTINGS_MODULE=onlineweb4.settings
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = tests, flake8, isort
envlist = tests, flake8, isort, black
skipsdist = True

[testenv]
Expand All @@ -10,6 +10,7 @@ whitelist_externals = npm
commands =
isort: isort -rc -c apps middleware scripts utils
flake8: flake8 apps middleware scripts utils
black: black --check apps middleware scripts utils

[testenv:tests]
deps =
Expand Down

0 comments on commit 49c759e

Please sign in to comment.