Skip to content

Commit dfb9ee8

Browse files
committed
Add code formatting check to Makefile
Add code formatting check to Makefile using the black utility. The Makefile commands .black-check and .black-format are added, similar to the main st2 repo.
1 parent c90191d commit dfb9ee8

File tree

4 files changed

+32
-3
lines changed

4 files changed

+32
-3
lines changed

Makefile

+16-2
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,10 @@ all: requirements lint
7777
all-ci: compile .flake8 .pylint
7878

7979
.PHONY: lint
80-
lint: requirements flake8 pylint
80+
lint: requirements flake8 pylint black-check
8181

8282
.PHONY: .lint
83-
.lint: compile .flake8 .pylint
83+
.lint: compile .flake8 .pylint .black-check
8484

8585
.PHONY: flake8
8686
flake8: requirements .clone_st2_repo .flake8
@@ -114,6 +114,20 @@ compilepy3:
114114
@echo
115115
. $(VIRTUALENV_DIR)/bin/activate; pylint -j $(PYLINT_CONCURRENCY) -E --rcfile=./lint-configs/python/.pylintrc --load-plugins=pylint_plugins.api_models --load-plugins=pylint_plugins.db_models st2rbac_backend/
116116

117+
.PHONY: .black-check
118+
.black-check:
119+
@echo
120+
@echo "================== black ===================="
121+
@echo
122+
. $(VIRTUALENV_DIR)/bin/activate; black --config pyproject.toml st2rbac_backend bin setup.py -l 100 --check
123+
124+
.PHONY: .black-format
125+
.black-format:
126+
@echo
127+
@echo "================== black ===================="
128+
@echo
129+
. $(VIRTUALENV_DIR)/bin/activate; black --config pyproject.toml st2rbac_backend bin setup.py -l 100
130+
117131
.PHONY: .unit-tests
118132
.unit-tests:
119133
@echo

lint-configs/python/.flake8

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
max-line-length = 100
33
# L102 - apache license header
44
enable-extensions = L101,L102
5-
ignore = E128,E402,E722,W504
5+
ignore = E128,E402,E722,W504,E203,W503
66
exclude=*.egg/*,build,dist
77

88
# Configuration for flake8-copyright extension

pyproject.toml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[tool.black]
2+
max-line-length = 100
3+
target_version = ['py36']
4+
include = '\.pyi?$'
5+
exclude = '''
6+
(
7+
/(
8+
| \.git
9+
| \.virtualenv
10+
| __pycache__
11+
| test_content_version
12+
)/
13+
)
14+
'''

test-requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
black
12
isort>=4.2.5

0 commit comments

Comments
 (0)