From 1be5330f0383d59e68af5f87ca4a17b530045e20 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Mon, 27 May 2024 20:33:48 -0400 Subject: [PATCH 1/5] chore: Add pydocstyle checks to ruff config --- pyproject.toml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 855693a..e55d071 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -82,6 +82,7 @@ extend-select = [ "E", "W", "I", + "D", "UP", "YTT", "S", @@ -101,6 +102,10 @@ extend-select = [ ] ignore = [ "ISC001", + "D105", + "D107", + "D203", + "D213", ] [tool.ruff.lint.flake8-quotes] From 1b458dbd913bbc3a0d3280e3a338b8498502589e Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Mon, 27 May 2024 20:34:42 -0400 Subject: [PATCH 2/5] doc: Update docstrings with pydocstyle fixes --- src/bids_validator/bids_validator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bids_validator/bids_validator.py b/src/bids_validator/bids_validator.py index 2d2a9e0..b48f9ae 100644 --- a/src/bids_validator/bids_validator.py +++ b/src/bids_validator/bids_validator.py @@ -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): From 50d4cba028ba945ffc194ab631e4660d2a733df1 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Mon, 27 May 2024 20:38:20 -0400 Subject: [PATCH 3/5] chore(tox): Add style environment --- tox.ini | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tox.ini b/tox.ini index b970640..4abc7ab 100644 --- a/tox.ini +++ b/tox.ini @@ -59,6 +59,17 @@ extras = doc commands = make -C doc html +[testenv:style] +description = Check and attempt to fix style +labels = check +deps = + ruff +skip_install = true +commands = + ruff check --fix src/ + ruff format src/ + ruff check --select ISC001 --fix src/ + [testenv:spellcheck] description = Check spelling labels = check From 18c7afd91c05cf43ace72cfc301439c9129814b1 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Mon, 27 May 2024 20:44:17 -0400 Subject: [PATCH 4/5] chore: Use tox for style and spelling checks --- .github/workflows/build-test-deploy.yml | 5 --- .github/workflows/checks.yml | 42 +++++++++++++++++++++++++ .github/workflows/codespell.yml | 24 -------------- tox.ini | 6 ++++ 4 files changed, 48 insertions(+), 29 deletions(-) create mode 100644 .github/workflows/checks.yml delete mode 100644 .github/workflows/codespell.yml diff --git a/.github/workflows/build-test-deploy.yml b/.github/workflows/build-test-deploy.yml index 0534b91..b38d516 100644 --- a/.github/workflows/build-test-deploy.yml +++ b/.github/workflows/build-test-deploy.yml @@ -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 diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000..aec8034 --- /dev/null +++ b/.github/workflows/checks.yml @@ -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 }} diff --git a/.github/workflows/codespell.yml b/.github/workflows/codespell.yml deleted file mode 100644 index 1ec2904..0000000 --- a/.github/workflows/codespell.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -name: Codespell - -on: - push: - branches: [main] - pull_request: - branches: [main] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - codespell: - name: Check for spelling errors - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - uses: codespell-project/actions-codespell@v2 - with: - ignore_words_list: ro,anser,te,tage,afterall,nwe,nin,nd,falsy - skip: package-lock.json diff --git a/tox.ini b/tox.ini index 4abc7ab..22806c4 100644 --- a/tox.ini +++ b/tox.ini @@ -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 @@ -21,6 +23,10 @@ DEPENDS = full: full pre: pre +CHECK = + style: style + spellcheck: spellcheck + [testenv] description = Pytest with coverage labels = test From 0459af5f12c48d5fa7813d3ed4b449d47280cf0e Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Wed, 29 May 2024 16:28:51 -0400 Subject: [PATCH 5/5] chore(tox): Set check and fix versions of style/spellcheck --- tox.ini | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tox.ini b/tox.ini index 22806c4..cc3966e 100644 --- a/tox.ini +++ b/tox.ini @@ -65,25 +65,28 @@ extras = doc commands = make -C doc html -[testenv:style] +[testenv:style{,-fix}] description = Check and attempt to fix style labels = check deps = ruff skip_install = true commands = - ruff check --fix src/ - ruff format src/ - ruff check --select ISC001 --fix src/ + 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] +[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 =