Skip to content

Commit

Permalink
chore: Use tox for style and spelling checks (#3)
Browse files Browse the repository at this point in the history
* chore: Add pydocstyle checks to ruff config

* doc: Update docstrings with pydocstyle fixes

* chore(tox): Add style environment

* chore: Use tox for style and spelling checks

* chore(tox): Set check and fix versions of style/spellcheck
  • Loading branch information
effigies authored May 29, 2024
1 parent cdd1f92 commit dc9196a
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 31 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/build-test-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,6 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}

- name: Check formatting
run: |
pipx run flake8 src
pipx run pydocstyle src
release-pypi:
name: Publish released package to pypi.org
environment: release-pypi
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
name: Checks

on:
push:
branches: [main]
pull_request:
branches: [main]

workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# Force tox and pytest to use color
env:
FORCE_COLOR: true

permissions:
contents: read

jobs:
codespell:
name: Check for spelling errors
runs-on: ubuntu-latest
strategy:
matrix:
check: ['style', 'spellcheck']

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
- name: Install tox
run: |
python -m pip install --upgrade pip
python -m pip install tox tox-gh-actions
- name: Show tox config
run: tox c
- name: Run tox
run: tox -e ${{ matrix.check }}
24 changes: 0 additions & 24 deletions .github/workflows/codespell.yml

This file was deleted.

5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ extend-select = [
"E",
"W",
"I",
"D",
"UP",
"YTT",
"S",
Expand All @@ -101,6 +102,10 @@ extend-select = [
]
ignore = [
"ISC001",
"D105",
"D107",
"D203",
"D213",
]

[tool.ruff.lint.flake8-quotes]
Expand Down
1 change: 1 addition & 0 deletions src/bids_validator/bids_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class LoggingContext:
Handler to add temporarily. If None, no handler is added.
close : bool
Whether to close the handler after removing it. Defaults to True.
"""

def __init__(self, logger, level=None, handler=None, close=True):
Expand Down
24 changes: 22 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ requires =
envlist =
py3{8,9,10,11,12}-{full,pre}
py38-min
style
spellcheck
skip_missing_interpreters = true

# Configuration that allows us to split tests across GitHub runners effectively
Expand All @@ -21,6 +23,10 @@ DEPENDS =
full: full
pre: pre

CHECK =
style: style
spellcheck: spellcheck

[testenv]
description = Pytest with coverage
labels = test
Expand Down Expand Up @@ -59,14 +65,28 @@ extras = doc
commands =
make -C doc html

[testenv:spellcheck]
[testenv:style{,-fix}]
description = Check and attempt to fix style
labels = check
deps =
ruff
skip_install = true
commands =
fix: ruff check --fix src/
fix: ruff format src/
fix: ruff check --select ISC001 --fix src/
!fix: ruff check src/
!fix: ruff format --diff src/

[testenv:spellcheck{,-fix}]
description = Check spelling
labels = check
deps =
codespell[toml]
skip_install = true
commands =
codespell . {posargs}
fix: codespell -w {posargs}
!fix: codespell {posargs}

[testenv:build{,-strict}]
labels =
Expand Down

0 comments on commit dc9196a

Please sign in to comment.