Update .pre-commit-config.yaml #25
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 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 | |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | |
- name: pyupgrade | |
run: | | |
pyupgrade $(git ls-files '*.py') | |
nbqa pyupgrade $(git ls-files '*.ipynb') | |
- name: Pylint | |
run: | | |
pylint --max-line-length=79 $(git ls-files '*.py') | |
nbqa pylint --max-line-length=79 $(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: Mypy | |
run: | | |
mypy $(git ls-files '*.py') | |
nbqa mypy $(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 |