Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check Python code with flake8 #677

Merged
merged 1 commit into from
Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[flake8]
exclude =
.git,
__pycache__,
build,
dist
ignore =
# https://flake8.pycqa.org/en/latest/user/error-codes.html
F401, # 'module' imported but unused
# https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes
E121, # continuation line under-indented for hanging indent
E122, # continuation line missing indentation or outdented
E126, # continuation line over-indented for hanging indent
E127, # continuation line over-indented for visual indent
E128, # continuation line under-indented for visual indent
E221, # multiple spaces before operator
E222, # multiple spaces after operator
E226, # missing whitespace around arithmetic operator
E231, # missing whitespace after ','
E241, # multiple spaces after ','
E402, # module level import not at top of file
E501, # line too long (> 79 characters)
E722, # do not use bare 'except'
W291, # trailing whitespace
W292, # no newline at end of file
W293, # blank line contains whitespace
W391, # blank line at end of file
W503, # line break before binary operator
W504 # line break after binary operator
statistics = True
7 changes: 3 additions & 4 deletions travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ if [ "${TRAVIS_PYTHON_VERSION}" = "2.7" ]; then
pip install -r requirements27.travis.txt
else
pip install -r requirements.travis.txt
pip install --no-binary rasterio rasterio
pip install rasterio
pip install --upgrade numpy
fi
if [ "${RUN_TYPE}" = "misc" ]; then
pip install --upgrade jupyter
pip install nbconvert
pip install pylint pylint-exit
pip install flake8 pylint pylint-exit
pip install jupyter nbconvert
fi
pip install https://github.com/modflowpy/pymake/zipball/master
pip install shapely[vectorize]
Expand Down
11 changes: 8 additions & 3 deletions travis/script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,20 @@ if [ "${RUN_TYPE}" = "test" ]; then
nosetests -v --with-id --with-timer -w ./autotest \
--with-coverage --cover-package=flopy
elif [ "${RUN_TYPE}" = "misc" ]; then
echo "Checking Python code..."
echo "Checking Python code with flake8..."
flake8 --exit-zero
echo "Checking Python code with pylint..."
pylint --jobs=2 --errors-only ./flopy || pylint-exit $?
echo "TODO: exit code was $?"
if [ $? -ne 0 ]; then
echo "An error occurred while running pylint." >&2
exit 1
fi
echo "Running notebook autotest suite..."
nosetests -v autotest_scripts.py --with-id --with-timer -w ./autotest \
--with-coverage --cover-package=flopy
nosetests -v autotest_notebooks.py --with-id --with-timer -w ./autotest \
--with-coverage --cover-package=flopy
else
echo "Unhandled RUN_TYPE=${RUN_TYPE}"
echo "Unhandled RUN_TYPE=${RUN_TYPE}" >&2
exit 1
fi