Skip to content

Commit 1b727a4

Browse files
author
cclauss
authored
Travis CI: Run flake8 tests to find syntax errors and undefined names
Add [flake8](http://flake8.pycqa.org) tests to find Python syntax errors and undefined names. * Remove versions of Python that are EOL like Python 2.6 and 3.3 -- https://docs.python.org/devguide/index.html#branchstatus __E901,E999,F821,F822,F823__ are the "_showstopper_" flake8 issues that can halt the runtime with a SyntaxError, NameError, etc. Most other flake8 issues are merely "style violations" -- useful for readability but they do not effect runtime safety. * F821: undefined name `name` * F822: undefined name `name` in `__all__` * F823: local variable name referenced before assignment * E901: SyntaxError or IndentationError * E999: SyntaxError -- failed to compile a file into an Abstract Syntax Tree
1 parent 9767a3d commit 1b727a4

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

.travis.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,24 @@
1+
sudo: false
12
language: python
23
cache: pip
34
python:
45
- "3.6"
56
- "3.5"
67
- "3.4"
7-
- "3.3"
88
- "2.7"
9-
- "2.6"
10-
11-
sudo: false
12-
13-
# command to install dependencies, e.g. pip install -r requirements.txt
14-
# These packages only exist on Ubuntu 13.04 and newer:
15-
# No dependencies currently unless using Python 2.6.
169

1710
install:
18-
- if [[ $TRAVIS_PYTHON_VERSION == 2.6* ]]; then pip install -r requirements_py26.txt; fi
1911
- python setup.py install
2012

13+
before_script:
14+
# 1) stop the build if there are Python syntax errors or undefined names
15+
# 2) exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
16+
- if [[ $TRAVIS_PYTHON_VERSION == 3.6 ]]; then
17+
pip install flake8;
18+
flake8 . --count --exit-zero --select=E901,E999,F821,F822,F823 --show-source --statistics;
19+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics;
20+
fi
21+
2122
# command to run tests, e.g. python setup.py test
2223

2324
script:

0 commit comments

Comments
 (0)