neuroinformatics-unit / python-cookiecutter

Utility to create a basic Python project structure with tests, CI etc.
BSD 3-Clause "New" or "Revised" License
20 stars 3 forks source link

Add codespell to test contributed here materials against typos, and fix some typos #103

Closed yarikoptic closed 5 months ago

yarikoptic commented 5 months ago

Description

Fix and prevent future common typos using https://github.com/codespell-project/codespell

Let me know if you want to add support for codespell into the template

Why is this PR needed?

Typos are there and more might sneak in

What does this PR do?

adds pre-commit and github workflow (let me know if I should remove) and fixes some typos

Checklist:

adamltyson commented 5 months ago

@neuroinformatics-unit/neuroinformatics-all this looks nice, shall we add it to the cookiecutter template itself (and by extension, other repos)?

niksirbi commented 5 months ago

I'm in favour of it. We are already using it on some of our other repos anyway.

alessandrofelder commented 5 months ago

Happy with it too.

sfmig commented 5 months ago

Just FYI: ARC colleagues recommend their usage but agreed not to add it to their cookiecutter template, due to false positives and it sometimes breaking their code. I have no experience using it as a pre-commit though.

yarikoptic commented 5 months ago

FWIW it is always a good practice to review pre-commit's changes. But indeed in case of a "heavy" pre-commit changes (black etc) it might be tricky... but in this case it doesn't even apply

since codespell pre-commit hook by default is just a checker, not a writer (need to pass `-w` option to make that happen) ```shell ❯ echo Installating >> README.md changes on filesystem: README.md | 1 + ❯ git commit -m 'Adding a typo' -a check docstring is first.............................(no files to check)Skipped check that executables have shebangs.................(no files to check)Skipped check for merge conflicts................................................Passed fix end of files.........................................................Passed mixed line ending........................................................Passed fix requirements.txt.................................(no files to check)Skipped trim trailing whitespace.................................................Passed ruff.................................................(no files to check)Skipped black................................................(no files to check)Skipped codespell................................................................Failed - hook id: codespell - exit code: 65 README.md:308: Installating ==> Installing ❯ git commit -m 'Adding a typo' -a check docstring is first.............................(no files to check)Skipped check that executables have shebangs.................(no files to check)Skipped check for merge conflicts................................................Passed fix end of files.........................................................Passed mixed line ending........................................................Passed fix requirements.txt.................................(no files to check)Skipped trim trailing whitespace.................................................Passed ruff.................................................(no files to check)Skipped black................................................(no files to check)Skipped codespell................................................................Failed - hook id: codespell - exit code: 65 README.md:308: Installating ==> Installing ```

so the worst effect from false-positive - inability to commit until white-listing that particular hit one way or another.

adamltyson commented 5 months ago

Thanks @yarikoptic. I'll raise a seperate PR to make it part of the template itself.