astral-sh / ruff

An extremely fast Python linter and code formatter, written in Rust.
https://docs.astral.sh/ruff
MIT License
30.94k stars 1.02k forks source link

Implement flake8-spellcheck #5014

Open gaborbernat opened 1 year ago

gaborbernat commented 1 year ago

👍 or another spellcheck variant 😊

calumy commented 1 year ago

Similar to #1628

charliermarsh commented 1 year ago

I think my opinion here is mostly the same as it was before: I feel like typo correction is better handled by multi-language or language-agnostic tooling, like typos, which works on Python but other sources too.

gaborbernat commented 1 year ago

I think that partially makes sense. However, they are some language specific constructs here, for example using snake casing to tokenize the source code, such as variable names or function names. Furthermore, it'll probably is a python specific extension/ allow list of words/ concepts. Finally would be nice if you could set up these tool from pypi like all other linting tools.

charliermarsh commented 1 year ago

Yeah, I think the argument I agree with most here is that it'd be nice to have the spellcheck unified with the rest of the Ruff linting stack (i.e., not a separate tool).

FWIW, typos does handle casing as you would expect since it is designed to lint "source code":

❯ typos foo.py
error: `helo` should be `hello`
  --> foo.py:1:1
  |
1 | helo_goodbye = 1
  | ^^^^
  |
error: `helo` should be `hello`
  --> foo.py:2:1
  |
2 | heloGoodbye = 1
  | ^^^^
  |
asears commented 11 months ago

This would be helpful for those currently leveraging flake8-spellcheck, the last plugin before moving to ruff completely. flake8-spellcheck includes python & django dictionaries. It hasn't been updated for about a year and a half. It would be great to have a python-specific spell checker with the speed of ruff.

https://github.com/MichaelAquilina/flake8-spellcheck/blob/main/flake8_spellcheck/__init__.py

ashrub-holvi commented 4 weeks ago

I had no experience with typos or codespell yet, but feels like checking source code just like text files may produce a lot of false errors. So, perhaps good to have an option to check comments and docstrings only, because on code review we reading code much more careful than non-code parts.