Python linting #694
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow will lint python code with flake8 and flake8-nb. | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | |
name: Python linting | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
schedule: | |
- cron: '30 5 * * *' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements-linting.txt | |
- name: Check sorted python imports using isort | |
run: | | |
isort . -c | |
- name: Lint code with flake8 | |
run: | | |
# stop the build if there are Python syntax errors or undefined names | |
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | |
# The GitHub editor is 127 chars wide. | |
flake8 . --count --max-complexity=30 --max-line-length=127 --statistics | |
# Check for cyclometric complexity for specific files where this metric has been | |
# reduced to ten and below | |
flake8 dice_ml/data_interfaces/ --count --max-complexity=10 --max-line-length=127 | |
- name: Lint notebooks with flake8_nb | |
run: | | |
# stop the build if there are flake8 errors in notebooks | |
flake8_nb docs/source/notebooks/ --statistics --max-line-length=127 |