Skip to content

workflows: add spell checker for PR changes#7432

Closed
ES-Alexander wants to merge 1 commit into
ArduPilot:masterfrom
ES-Alexander:check-spelling-on-prs
Closed

workflows: add spell checker for PR changes#7432
ES-Alexander wants to merge 1 commit into
ArduPilot:masterfrom
ES-Alexander:check-spelling-on-prs

Conversation

@ES-Alexander

@ES-Alexander ES-Alexander commented Feb 24, 2026

Copy link
Copy Markdown
Contributor

Following on from discussion in #7426, this PR adds a workflow for codespell checking to the lines added1 in a PR.

The idea is that contributors and reviewers/maintainers can evaluate whether errors need fixing on a case-by-case basis, and choose to ignore them if they want to. It does still check the unchanged words in a line that was changed, but that seems unlikely to cause substantial issues or overhead.

Example output can be found here.


As a somewhat related note, it seems my assumption that codespell works like other spell checkers is incorrect, and in fact:

It does not check for word membership in a complete dictionary, but instead looks for a set of common misspellings. Therefore it should catch errors like "adn", but it will not catch "adnasdfasdf". This also means it shouldn't generate false-positives when you use a niche term it doesn't know about.

Given that, I agree we should consider @cclauss's idea of re-running it on all/most files at some kind of regular interval, but ideally that should be just when the library version gets updated (when there are likely to be new words in the dictionary). I haven't added it in this workflow, because I don't think PR contributors should need to be flagged for errors unrelated to their changes - if we add that it can be in a dedicated workflow that's independent of the PR process.

Footnotes

  1. "added" can be completely new lines, or modified lines (which diff considers as a deleted line and a new line to replace it). It does not check any removed content.

@Hwurzburg

Copy link
Copy Markdown
Contributor

I think the new pre-commit checks have codespell now

@cclauss

cclauss commented Mar 9, 2026

Copy link
Copy Markdown
Contributor

Yes...

- repo: https://github.com/codespell-project/codespell
rev: v2.4.2
hooks:
- id: codespell # See pyproject.toml for args
additional_dependencies:
- tomli

@ES-Alexander

ES-Alexander commented Mar 9, 2026

Copy link
Copy Markdown
Contributor Author

I think the new pre-commit checks have codespell now

Indeed, and it seems #7479 + #7480 conveniently ignored my concerns1 from #7426, which were the problem I was addressing with this PR (at the request/suggestion of @cclauss at the time).

Anyway, I don't plan to put more work into this - hopefully the issue ends up being insignificant 🤷‍♂️

Footnotes

  1. In short, checking spelling on all repo files for every PR may be annoying (and deterring to contributors) when errors are raised that are unrelated to the proposed changes, and needing to manually maintain a dictionary of whitelisted words seems more involved and error-prone than the risk of maintainers merging in true-positive detections.

@peterbarker

Copy link
Copy Markdown
Contributor
  1. In short, checking spelling on all repo files for every PR may be annoying (and deterring to contributors) when errors are raised that are unrelated to the proposed changes, and needing to manually maintain a dictionary of whitelisted words seems more involved and error-prone than the risk of maintainers merging in true-positive detections.

@cclauss has also fixed all problems that codespell has raised.

codespell doesn't actually check every word for being in a dictionary - it just looks for common mis-spellings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants