Skip to content

Commit cc5f9a4

Browse files
committed
Add black code formatter to the project.
1 parent 35a8fab commit cc5f9a4

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

Makefile

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
XARGS := xargs -0 $(shell test $$(uname) = Linux && echo -r)
22
GREP_T_FLAG := $(shell test $$(uname) = Linux && echo -T)
3+
BLACK_INSTALLED := $(shell python -m black --version 2>/dev/null)
34

45
all:
56
@echo "\nThere is no default Makefile target right now. Try:\n"
@@ -32,15 +33,29 @@ pyflakes:
3233
find . \( -name _build -o -name var -o -path ./docs \) -type d -prune -o -name '*.py' -print0 | $(XARGS) pyflakes
3334

3435
pep8: clean
35-
find . \( -name _build -o -name var \) -type d -prune -o -name '*.py' -print0 | $(XARGS) -n 1 pycodestyle --repeat --exclude=build/*,docs/* --ignore=E731,E402,W504
36+
find . \( -name _build -o -name var \) -type d -prune -o -name '*.py' -print0 | $(XARGS) -n 1 pycodestyle --repeat --exclude=build/*,docs/* --ignore=E731,E402,W504,W503,E203
3637

3738
test: clean
3839
py.test
3940

4041
coverage: clean
4142
py.test --cov-report term-missing --cov=uflash tests/
4243

43-
check: clean pep8 pyflakes coverage
44+
tidy:
45+
ifdef BLACK_INSTALLED
46+
python -m black -l79 .
47+
else
48+
@echo Black not present
49+
endif
50+
51+
black:
52+
ifdef BLACK_INSTALLED
53+
python -m black --check -l79 .
54+
else
55+
@echo Black not present
56+
endif
57+
58+
check: clean pep8 pyflakes black coverage
4459

4560
package: check
4661
python setup.py sdist

requirements.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ pyflakes
44
coverage
55
sphinx
66
pytest-cov
7-
nudatus>=0.0.2
7+
nudatus>=0.0.2
88

99
# Mock is bundled as part of unittest since Python 3.3
1010
# mock_open can't read binary data in <= 3.4.2
1111
mock ; python_version == '2.7' or python_version == '3.4'
12+
13+
# Black is only available for Python 3.6+
14+
black>=19.10b0;python_version>'3.5'

0 commit comments

Comments
 (0)