ci: spell-check the code as part of linting#1388
Conversation
benhoyt
left a comment
There was a problem hiding this comment.
Looks reasonable to me. Out of interest, what does this check? Just code comments and strings?
| - id: ruff-format | ||
| args: [ --preview ] | ||
| # Spellcheck the code. | ||
| - repo: https://github.com/codespell-project/codespell |
There was a problem hiding this comment.
Is this, or can we set this, to British English (Canonical style)? At a cursory look "socio-economic" is more common in British English, so that made me wonder.
There was a problem hiding this comment.
My understanding is that it will currently accept both en-UK and en-US spellings, so it fails to help with that. There is an option to make en-UK spellings an error with the en-US the suggestion, but there doesn't seem to be the reverse option, which is what we would want.
There's a lot of customisation possible in terms of which dictionaries are used, so maybe it's possible to eliminate en-US? I'm not totally sure, and the docs don't seem to say anything about it.
I think it's doing a regular expression match for
I think this 'look for misspellings' is how it manages to avoid having to look specifically for words in comments, strings, and so on. If I add a line |
Add a `codespell` run as part of the `tox -e lint` environment, to pick up any spelling errors that might be missed in review. It's also added to the pre-commit checks, for anyone using those. The PR also makes 4 corrections, which codespell found. Two are debatable (whether or not to hyphenate) but two are definite errors. This adds a new (lint-time) dependency of codespell - it's also used in the default charmcraft profile, I've used it before, and it has a [good Snyk score](https://snyk.io/advisor/python/codespell) so it seems ok to me. I have lightly skimmed the code, but not read it in depth.
Add a
codespellrun as part of thetox -e lintenvironment, to pick up any spelling errors that might be missed in review. It's also added to the pre-commit checks, for anyone using those.The PR also makes 4 corrections, which codespell found. Two are debatable (whether or not to hyphenate) but two are definite errors.
This adds a new (lint-time) dependency of codespell - it's also used in the default charmcraft profile, I've used it before, and it has a good Snyk score so it seems ok to me. I have lightly skimmed the code, but not read it in depth.