Skip to content

Commit 14795a1

Browse files
authored
GitHub Action to lint Python code
https://flake8.pycqa.org/en/latest/user/error-codes.html On the flake8 test selection, this PR does _not_ focus on "_style violations_" (the majority of flake8 error codes that [__psf/black__](https://github.com/psf/black) can autocorrect). Instead, these tests are focus on runtime safety and correctness: * E9 tests are about Python syntax errors usually raised because flake8 can not build an Abstract Syntax Tree (AST). Often these issues are a sign of unused code or code that has not been ported to Python 3. These would be compile-time errors in a compiled language but in a dynamic language like Python, they result in the script halting/crashing on the user. * F63 tests are usually about the confusion between identity and equality in Python. Use ==/!= to compare str, bytes, and int literals is the classic case. These are areas where __a == b__ is True but __a is b__ is False (or vice versa). Python >= 3.8 will raise SyntaxWarnings on these instances. * F7 tests logic errors and syntax errors in type hints * F82 tests are almost always _undefined names_ which are usually a sign of a typo, missing imports, or code that has not been ported to Python 3. These also would be compile-time errors in a compiled language but in Python, a __NameError__ is raised which will halt/crash the script on the user.
1 parent 78b9476 commit 14795a1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

.github/workflows/pythonapp.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@ jobs:
99

1010
steps:
1111
- uses: actions/checkout@v2
12-
- name: Set up Python 3.7
13-
uses: actions/setup-python@v1
12+
- name: Set up Python 3.8
13+
uses: actions/setup-python@v2
1414
with:
15-
python-version: 3.7
15+
python-version: 3.8
1616
- name: Install dependencies
1717
run: |
18-
python -m pip install --upgrade pip
18+
python -m pip install --upgrade pip flake8
19+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
1920
pip install quantaxis -U
2021
2122

0 commit comments

Comments
 (0)