-
Notifications
You must be signed in to change notification settings - Fork 467
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
assertIn false positivies #3430
Comments
How about moving it to the code dictionary? Merge requests welcome. |
Happy to try to fix this, tracked it down to this entry in the global dict: https://github.com/codespell-project/codespell/blob/master/codespell_lib/data/dictionary.txt#L5633 What I'm not clear on is how moving this to Is there a separate place in codespell to specify conditional code-related ignores of items from the dictionary that would otherwise make sense in normal text? |
By design, codespell is mostly case-insensitive and doesn't make a difference between |
OK, so how would I define an ignore rule for |
There's the code dictionary. Because codespell is language agnostic, you cannot define a rule for Python files only. |
The code dictionary seems to have definitions of common misspellings of code, e.g.,
these make sense The problem is that a simple pure Python built-in snippet like import unittest
class MyTest(unittest.TestCase):
def some_test(self):
self.assertIn("a", ["b"]) makes codespell think that the code line is a misspelling with suggestions corresponding to the non-code dictionary: https://github.com/codespell-project/codespell/blob/master/codespell_lib/data/dictionary.txt#L5633 So are you saying that this is a broader issue that the non-code dictionary is running and making suggestions on code instead of just normal text? |
Everything's text as far as codespell is concerned, whether Shakespeare prose or source code. You just get to select the typo lists/dictionaries you want to use - the default ones or your own selection. The code dictionary contains typos that are invalid English words in a general context, but are valid words in the context of source code. You're supposed to avoid the code dictionary when spellchecking source code - or use it at the expense of more false positives in the hope of catching a few true positives. |
Related issue: codespell-project/codespell#3430
Related issue: codespell-project/codespell#3430
Temporary resolution until codespell-project/codespell#3430 is fixed
Temporary resolution until codespell-project/codespell#3430 is fixed
Temporary resolution until codespell-project/codespell#3430 is fixed
* build(deps): bump ruff from 0.4.5 to 0.4.6 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.4.5 to 0.4.6. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](astral-sh/ruff@v0.4.5...v0.4.6) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <[email protected]> * deps: keep codespell below 2.3 Because of codespell-project/codespell#3430 --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Pete Gadomski <[email protected]>
And ensure `assertIn` is ignored, as that gives LOTS of false positives. Hopefully the upstream issue is solved: codespell-project/codespell#3430
I've opened #3469 for this specific aspect.
This shouldn't be in there as it will likely rarely be triggered, if you're checking code you won't use this dictionary (but it might not pass CI in the normal one where it would work because argv isn't a word in a proper dictionary.
This is a numpy function, so wants skipping if you're checking code (so it doesn't become arrange or a range): |
Can be closed after moving For |
Codespell 2.3.0 started to complain about assertIn method:
I know I can allow this particular word, but complaining on standard Python test suite API seems a bit annoying.
The text was updated successfully, but these errors were encountered: