Skip to content

Update .pre-commit-config.yaml #41

Update .pre-commit-config.yaml

Update .pre-commit-config.yaml #41

Workflow file for this run

# This workflow runs when a commit is pushed to the "main" branch or
# a pull request is opened against the "main" branch.
#
# It uses:
# - Pylint to lint the Python code
# - Black to format the Python code
# - Isort to sort the Python imports
# - Prettier to check for general formatting issues in yaml, json, README, etc.
name: lint
on:
push:
branches:
- main
pull_request:
branches:
- main
permissions:
contents: read
jobs:
lint:
timeout-minutes: 5
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.12'] # Always include the latest python version
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install "nbqa[toolchain]" pylint isort "black[jupyter]" mypy pyupgrade flake8-variables-names pep8-naming flake8-functions-names pandas-stubs git+https://github.com/numpy/numpy-stubs mypy-extensions types-requests types-PyYAML types-setuptools
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Flake8
run: |
flake8 --ignore=E203,E501,W291,F821,F401 $(git ls-files '*.py')
nbqa flake8 --ignore=E203,E501,W291,F821,F401 $(git ls-files '*.ipynb')
- name: Pylint
run: |
pylint --max-line-length=79 --const-naming-style=any --disable=E0401,W1514,C0200 --disable=import-error $(git ls-files '*.py')
nbqa pylint --max-line-length=79 --const-naming-style=any --disable=E0401,W1514,C0200 --disable=import-error $(git ls-files '*.ipynb')
- name: Mypy
run: |
mypy --ignore-missing-imports $(git ls-files '*.py')
nbqa mypy --ignore-missing-imports $(git ls-files '*.ipynb')
- name: isort
run: |
isort --check-only --diff $(git ls-files '*.py')
nbqa isort --check-only --diff $(git ls-files '*.ipynb')
- name: Black
run: |
black --check --diff --line-length=79 $(git ls-files '*.py')
nbqa black --check --diff --line-length=79 $(git ls-files '*.ipynb')
- name: pyupgrade
run: |
pyupgrade $(git ls-files '*.py')
nbqa pyupgrade $(git ls-files '*.ipynb')
prettier:
timeout-minutes: 1
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Check formatting
run: npx --yes prettier --check