Skip to content
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

Allow alternative to codespell in sp-repo-review #459

Closed
burgholzer opened this issue Aug 5, 2024 · 3 comments · Fixed by #460
Closed

Allow alternative to codespell in sp-repo-review #459

burgholzer opened this issue Aug 5, 2024 · 3 comments · Fixed by #460

Comments

@burgholzer
Copy link
Contributor

PC160 currently suggests the use of codespell in pre-commit.
However, codespell can be quite slow at times and can easily miss certain typos.
While looking for alternatives, I stumbled upon the crate-ci/typos repository that is also used by ruff in favor of codespell.
The tool has quite an easy config scheme, is drastically faster, and also provides auto-fix support. Furthermore, it caught at least some additional typos that were not spotted by codespell when we introduced the new tool for our framework (cda-tum/mqt-core#625).

Right now, the use of the crate-ci/typos in favor of codespell requires us to ignore "PC160".

Would it make sense to expand the scope of the rule a little bit to something like "Uses a spellchecker" and allow for codespell and/or crate-ci/typos to be used?

@henryiii
Copy link
Collaborator

henryiii commented Aug 5, 2024

Codespell does support auto-fixes.

Would it make sense to expand the scope of the rule a little bit to something like "Uses a spellchecker" and allow for codespell and/or crate-ci/typos to be used?

Absolutely. We already do this with black/ruff, flake8/ruff, nox/tox/hatch/spin, etc.

@burgholzer
Copy link
Contributor Author

Codespell does support auto-fixes.

👍🏼

Would it make sense to expand the scope of the rule a little bit to something like "Uses a spellchecker" and allow for codespell and/or crate-ci/typos to be used?

Absolutely. We already do this with black/ruff, flake8/ruff, nox/tox/hatch/spin, etc.

I am not too familiar with the repo-review part of this project. However, I could try to submit a corresponding PR based on how this is handled for the other combinations of tools.
Or would you rather work on this yourself?

@henryiii
Copy link
Collaborator

henryiii commented Aug 5, 2024

Well, I would have said PR, but I see a bit of cleanup I could do on the base class. It's at

class PC110(PreCommit):
"Uses black or ruff-format"
repo = "https://github.com/psf/black-pre-commit-mirror"
renamed = "https://github.com/psf/black"
alternate = "https://github.com/astral-sh/ruff-pre-commit"
@classmethod
def check(cls, precommit: dict[str, Any]) -> bool | None | str:
"Must have `{self.repo}` or `{self.alternate}` + `id: ruff-format` in `.pre-commit-config.yaml`"
for repo in precommit.get("repos", {}):
if repo.get("repo", "").lower() == cls.alternate and any(
hook.get("id", "") == "ruff-format" for hook in repo.get("hooks", {})
):
return True
return super().check(precommit)
. Let me check.

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 a pull request may close this issue.

2 participants