Skip to content

Commit 42c3ac7

Browse files
authored
Add pre-commit & flake8 config files; run pre-commit hooks on GA (#298)
* Add pre-commit & flake8 congif files * Add pre-commit hook run to GA workflow * Rename GA workflows * Exclude doc/conf.py from pre-commit linter * Apply black formatting to doc/conf.py * Only exclude doc/conf.py from flake8 check * Only exclude doc/conf.py from flake8 check * Format doc/conf.py * Configure pep8speaks to not comment on line length up to 90 chars long
1 parent 9d33edc commit 42c3ac7

File tree

6 files changed

+129
-89
lines changed

6 files changed

+129
-89
lines changed

.flake8

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# See:
2+
#
3+
# https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes (E, W)
4+
# https://flake8.pycqa.org/en/latest/user/error-codes.html (F)
5+
# https://github.com/PyCQA/flake8-bugbear
6+
#
7+
# for error codes. And
8+
#
9+
# https://flake8.pycqa.org/en/latest/user/violations.html#selecting-violations-with-flake8
10+
#
11+
# for error classes selected below.
12+
13+
[flake8]
14+
max-line-length = 80
15+
select = C,E,F,W,B,B950
16+
ignore = E501, W503, E203

.github/workflows/docs_build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build cesium docs
1+
name: Build docs
22

33
on:
44
push:

.github/workflows/tests.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Run cesium test suite
1+
name: Test Cesium
22

33
on:
44
push:
@@ -41,6 +41,12 @@ jobs:
4141
4242
which python; python --version
4343
44+
- name: Formatting and linting checks
45+
if: github.ref != 'refs/heads/master'
46+
run: |
47+
pip install pre-commit
48+
pre-commit run --from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}
49+
4450
- name: Run test suite
4551
run: |
4652
if [[ -n $COVERAGE ]]; then

.pep8speaks.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@ scanner:
22
diff_only: True # Errors caused by only the patch are shown, not the whole file
33

44
pycodestyle:
5-
max-line-length: 80 # Default is 79 in PEP8
5+
max-line-length: 90 # Default is 79 in PEP8
66
ignore: # Errors and warnings to ignore
77
- W391
88
- E203
99

1010
no_blank_comment: True # If True, no comment is made when the bot does not find any pep8 errors
11-

.pre-commit-config.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v2.5.0
4+
hooks:
5+
- id: check-yaml
6+
- id: end-of-file-fixer
7+
- id: trailing-whitespace
8+
- repo: https://github.com/python/black
9+
rev: 20.8b1
10+
hooks:
11+
- id: black
12+
pass_filenames: true
13+
- repo: https://gitlab.com/pycqa/flake8
14+
rev: 3.8.4
15+
hooks:
16+
- id: flake8
17+
pass_filenames: true
18+
exclude: doc/conf.py

0 commit comments

Comments
 (0)