-
Notifications
You must be signed in to change notification settings - Fork 49
55 lines (46 loc) · 1.81 KB
/
lint.yml
File metadata and controls
55 lines (46 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Lint
on:
pull_request:
types: [opened, synchronize, reopened]
# To cancel a currently running workflow from the same PR, branch or tag when a new workflow is triggered
# https://stackoverflow.com/a/72408109
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
- name: Install linters
run: pip install autopep8 flake8 isort
- name: Check import sorting with isort
run: isort --check-only --diff lightning_pose tests
# Reads config from [tool.isort] in pyproject.toml
- name: Check formatting with autopep8
run: autopep8 --diff --recursive --exit-code lightning_pose tests
# Reads config from [tool.autopep8] in pyproject.toml
- name: Lint with flake8 (critical errors only)
run: flake8 lightning_pose tests --select=E9,F63,F7,F82
# Reads config from .flake8 file
# F9: syntax errors, can't parse file
# F63: invalid ** use in `assert` or `raise`
# F7: syntax errors in type annotations
# F82: undefined names (var or function that was never imported)
- name: Show fix instructions if formatting needed
if: failure()
run: |
echo ""
echo "Linting failed!"
echo ""
echo "To fix formatting issues locally, run:"
echo " autopep8 --in-place --recursive lightning_pose tests"
echo " isort lightning_pose tests"
echo ""
echo "To check for flake8 errors locally, run:"
echo " flake8 lightning_pose tests --select=E9,F63,F7,F82"
echo ""