Skip to content

Commit 344f349

Browse files
committed
Add support for linting Python
1 parent b1a8946 commit 344f349

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

tools/git/hooks/pre-commit

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ run_lint() {
7979
# Lint Markdown files...
8080
files=$(echo "${changed_files}" | grep '\.md$' | tr '\n' ' ')
8181
if [[ -n "${files}" ]]; then
82-
make MARKDOWN_FILES="${files}" lint-markdown > /dev/null
82+
make MARKDOWN_FILES="${files}" lint-markdown > /dev/null >&2
8383
if [[ "$?" -ne 0 ]]; then
8484
echo '' >&2
8585
echo 'Markdown lint errors.' >&2
@@ -142,6 +142,23 @@ run_lint() {
142142
fi
143143
fi
144144

145+
# Lint Python files...
146+
files=$(echo "${changed_files}" | grep '\.py$' | tr '\n' ' ')
147+
if [[ -n "${files}" ]]; then
148+
make check-python-linters > /dev/null >&2
149+
if [[ "$?" -ne 0 ]]; then
150+
echo '' >&2
151+
echo 'Unable to lint Python files. Ensure that linters are installed.' >&2
152+
else
153+
make PYTHON_FILES="${files}" lint-python-files > /dev/null >&2
154+
if [[ "$?" -ne 0 ]]; then
155+
echo '' >&2
156+
echo 'Python lint errors.' >&2
157+
return 1
158+
fi
159+
fi
160+
fi
161+
145162
# TODO: if datapackage.json, validate via schema
146163

147164
return 0

0 commit comments

Comments
 (0)