Skip to content

Python linting

Python linting #1053

# This workflow will lint python code with flake8.
# 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@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
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