Skip to content

Commit 7c17b90

Browse files
committed
Added flake8 checks
1 parent a6a502e commit 7c17b90

4 files changed

Lines changed: 40 additions & 0 deletions

File tree

.flake8

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[flake8]
2+
max-line-length = 88
3+
extend-ignore = W503,E203,F401
4+
exclude = */sdk/*

.githooks/pre-push

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ source "${ROOT_DIR}/scripts/helpers"
55

66
./scripts/check_isort
77
./scripts/check_black
8+
./scripts/check_flake8
89

910
header "Proceeding with push"

.github/workflows/lint-and-test.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,15 @@ jobs:
2828
uses: actions/checkout@v2
2929
- name: Check code format
3030
run: ./scripts/check_black
31+
32+
flake8:
33+
runs-on: ubuntu-latest
34+
container:
35+
image: sergioteula/pytools
36+
volumes:
37+
- ${{github.workspace}}:/code
38+
steps:
39+
- name: Check out code
40+
uses: actions/checkout@v2
41+
- name: Check code errors
42+
run: ./scripts/check_flake8

scripts/check_flake8

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#! /bin/bash
2+
3+
ROOT_DIR="$(git rev-parse --show-toplevel)"
4+
source "${ROOT_DIR}/scripts/helpers"
5+
6+
header "Checking code errors with flake8"
7+
8+
if [ -n "$(check_if_installed docker)" ]; then
9+
docker run -v "${PWD}:/code" sergioteula/pytools flake8 --color always .
10+
elif [ -n "$(check_if_installed flake8)" ]; then
11+
flake8 --color always .
12+
else
13+
error "flake8 is not installed"
14+
exit 1
15+
fi
16+
17+
EXIT_CODE="$?"
18+
if [ "$EXIT_CODE" = "0" ]; then
19+
success "Code analysis with flake8 is correct"
20+
else
21+
error "There are errors detected by flake8"
22+
exit 1
23+
fi

0 commit comments

Comments
 (0)