we use a pep8
target in our repo's Makefile to check for PEP8 compliance on all python files:
## Check all python files for compatibility with PEP8
PEP8FLAGS := --ignore=E201,E202,E241,E265,E501,E711,E712,E713,E714,E721,W391,W291,W293,W601,W603
pep8:
pep8 $(PEP8FLAGS) .
I'd like to have a similar pep8-changes
target that only checks against the Python files changed in pull requests:
DIFF_FILES := (git diff --name-only --diff-filter=ACMR ; \ # ACMR: added/copied/modified/renamed
git diff --staged --name-only --diff-filter=ACMR ; \
git diff --name-only --diff-filter=ACMR upstream/master...) \
| sort | uniq | grep -e "\.py$$" | grep -v '__init__.py'
## Check all diff python files for compatibility with PEP8
pep8-changes:
pep8 $(PEP8FLAGS) --filename $(DIFF_FILES)
But I get the following error:
pep8 --exclude=sandbox,thirdparty --ignore=E201,E202,E241,E265,E501,E711,E712,E713,E714,E721,W391,W291,W293,W601,W603 --filename (git diff --name-only --diff-filter=ACMR ; \
/bin/sh: -c: line 0: syntax error near unexpected token `('
I'm not finding much help in the pep8 docs; I don't think the --diff
flag is what I'm looking for here. Any help is appreciated!
Okay got it. Issues seemed to be around escaping the
$
char. Here's the final: