Skip to content

🔧 Add codespell configuration and fix existing typos - #34

Merged
vanandrew merged 9 commits into
vanandrew:mainfrom
yarikoptic:enh-codespell
Aug 6, 2026
Merged

🔧 Add codespell configuration and fix existing typos#34
vanandrew merged 9 commits into
vanandrew:mainfrom
yarikoptic:enh-codespell

Conversation

@yarikoptic

@yarikoptic yarikoptic commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Add codespell spell-checking to warpkit.

Summary

  • Wire codespell into CI (.github/workflows/codespell.yml) and pre-commit.
  • Tune the config in [tool.codespell] (pyproject.toml) so the domain vocabulary (MR-physics terms, PyInstaller API, DICOM/BIDS metadata, vendored ROMEO port) does not produce false positives.
  • Fix the 7 real typos that codespell surfaced (all in comments/docstrings — no user-facing strings, identifiers, or public API touched).

Result: codespell passes with zero errors on the tree.

Config choices

Skip patterns and ignore-words-list rationale

Skip — all ./-anchored so they match the paths codespell walks when invoked as codespell .:

  • ./include/romeo/*, ./include/itk/* — vendored code (do not modify upstream)
  • ./build/*, ./.venv/* — build / venv artifacts
  • ./.git, ./.git-meta, ./.gitignore, ./.gitattributes — VCS metadata (.git-meta/ is a per-developer scratch dir for draft commit messages, which naturally contain typos-under-discussion)
  • *.pdf, *.lock — binary / generated

ignore-words-list (documented in-file with rationale):

word reason
te, tes MR-physics abbreviations for echo time / echo times (see CLAUDE.md)
nd DICOM ImageType flag ("Normalized Distortion-corrected") in BIDS fixtures
datas PyInstaller Analysis() parameter name in packaging/pyinstaller/
framei frame_i loop variable in tests/test_distortion.py
thirdparty Refers to ITK's ThirdParty/Eigen3 module in a CMakeLists.txt comment
Typos fixed (comments/docstrings only)
file before after note
include/utilities.h sequnce sequence @brief comment
include/warps.h displacment displacement // Pass displacement fields ... comment
warpkit/concurrency.py thre the "pass the result of the future" — ambiguous per codespell, clear from context
warpkit/unwrap.py verision version "dilated version of the mask" — ambiguous per codespell, clear from context
warpkit/unwrap.py threhold threshold "threshold the RD" comment
warpkit/unwrap.py occuring occurring "most often occurring multiple" comment
warpkit/utilities.py Displacment Displacement docstring return-value description

All fixes reviewed line-by-line: none touch identifiers, API surface, string literals, or regex patterns.

Extended-dictionary pass (for future auditors)

codespell --builtin clear,rare,usage,code,names was run as a follow-up audit. All remaining hits are false positives (real domain terms) and are left untouched:

  • sinc (include/warps.h) — the sinc interpolator
  • arange (tests) — np.arange
  • iff (tests) — mathematical "if and only if"
  • ba (warpkit/utilities.py) — SciPy iirfilter(output="ba") convention
  • master in tests/test_romeo.py and tests/data/test_data/*.json — legitimate references to ROMEO.jl's master branch and Siemens scanner sequence metadata, respectively

Not adding these to ignore-words-list since CI uses only the default clear,rare dictionaries where none are flagged.

Historical context

The project has had prior manual typo-fix commits (:memo: fix typo in import in README, :memo: fix README typo) — automated checking replaces the ad-hoc process.

Testing

  • uvx codespell — passes with exit 0
  • uvx pre-commit run --files <changed> — ruff-check, ruff-format, codespell all pass (pyright reports missing-import errors due to my local env not having the compiled extension + Python deps; unrelated to these changes, which only touch comments/docstrings)

CI safety

The workflow uses permissions: contents: read and pins codespell-project/actions-codespell to a full commit SHA (v2.2).

- Skip vendored ROMEO port (include/romeo), ITK-related headers
  (include/itk), and build/venv directories.
- Add ignore-words-list for domain terms and identifiers that codespell
  flags but are intentional:
    te, tes    — MR-physics abbreviations (echo time / echo times)
    nd         — DICOM ImageType flag in BIDS test fixtures
    datas      — PyInstaller Analysis() parameter name
    framei     — loop variable "frame i" in tests
    thirdparty — ITK's ThirdParty/Eigen3 module referenced in CMakeLists.txt
- Fix stale comment in .pre-commit-config.yaml (config lives in
  pyproject.toml, not the pre-commit yaml itself). Move the codespell
  hook's tomli additional_dependency in per codespell docs (no-op on
  Python ≥ 3.11 but harmless).

Reduces codespell false positives from 38 to 0. Remaining 7 hits are
real typos, fixed in follow-up commits.
Codespell reports `thre ==> three, there, their, the` as ambiguous.
From context ("pass thre result of the future to the post_fn"), the
intended word is clearly "the".
.git-meta is a per-developer scratch dir (git-excluded) used to hold
draft commit messages and PR bodies. Those drafts frequently discuss
typos being fixed, which causes codespell to flag them. Excluding the
dir keeps local codespell runs clean without affecting CI (which never
sees .git-meta since it isn't tracked).
Non-ambiguous typos flagged by codespell in code comments and
docstrings (no identifiers or user-facing strings touched):

- include/utilities.h:   sequnce      -> sequence
- include/warps.h:       displacment  -> displacement
- warpkit/unwrap.py:     threhold     -> threshold
- warpkit/unwrap.py:     occuring     -> occurring
- warpkit/unwrap.py:     verision     -> version (ambiguous per codespell,
                                                  clearly "version" from
                                                  context: "dilated version
                                                  of the mask")
- warpkit/utilities.py:  Displacment  -> Displacement

Codespell now passes cleanly.
Codespell walks paths as `./<rel-path>` when invoked from the project
root (which is what CI does with `codespell .`). The earlier bare
patterns like `include/romeo` did not match `./include/romeo/...` and
therefore silently failed to skip the vendored ROMEO port and other
excluded dirs — visible under the extended-dictionary pass
(`--builtin clear,rare,usage,code,names`) as spurious hits in
`include/romeo/`.

Rewrite the skip list to use `./`-anchored globs with trailing `/*`
where a directory tree is meant:
    ./include/romeo/*
    ./include/itk/*
    ./build/*
    ./.venv/*
    ./.git, ./.git-meta, ./.gitignore, ./.gitattributes

No effect on the default-dictionary pass (which found nothing in those
dirs to begin with) — this is a correctness fix that hardens the
config against future dictionary changes and extended-pass audits.
Copilot AI lite review requested due to automatic review settings August 4, 2026 18:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds automated spell-checking to the warpkit repository via codespell, and fixes a small set of existing typos (all in comments/docstrings), improving code hygiene without changing runtime behavior.

Changes:

  • Add codespell configuration under [tool.codespell] in pyproject.toml.
  • Wire codespell into both GitHub Actions (new workflow) and pre-commit.
  • Fix several spelling mistakes in comments/docstrings across Python and C++ headers.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
pyproject.toml Adds [tool.codespell] config (skip patterns, ignore word list, check-hidden).
.github/workflows/codespell.yml Introduces a CI job that runs codespell on pushes/PRs to main.
.pre-commit-config.yaml Adds the codespell pre-commit hook (with tomli for Python < 3.11).
warpkit/concurrency.py Fixes a comment typo.
warpkit/unwrap.py Fixes several comment typos.
warpkit/utilities.py Fixes a docstring typo in the return description.
include/warps.h Fixes a comment typo.
include/utilities.h Fixes a Doxygen @brief typo.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .github/workflows/codespell.yml
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.25%. Comparing base (827a8ba) to head (8c27407).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #34   +/-   ##
=======================================
  Coverage   96.25%   96.25%           
=======================================
  Files          18       18           
  Lines        1280     1280           
=======================================
  Hits         1232     1232           
  Misses         48       48           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@vanandrew vanandrew left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo fixes all look right. I checked the config too — removing ignore-words-list does give back the 38 hits, and the pinned SHA matches v2.2.

One problem with the skip globs, comment inline.

Comment thread pyproject.toml Outdated
Co-authored-by: Yaroslav Halchenko <debian@onerussian.com>

@vanandrew vanandrew left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@vanandrew
vanandrew merged commit 8c9f158 into vanandrew:main Aug 6, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants