Skip to content

Conversation

@pkestene
Copy link
Contributor

@pkestene pkestene commented Sep 7, 2025

Add pre-commit hooks config and fix reported typos

This is a companion PR to the one made in libsc : cburstedde/libsc#229

This PR adds configuration files for using pre-commit, e.g.

  • remove trailing white space,
  • end of file fixer,
  • spell checker (typos).

It can be run in command line terminal with pre-commit run --all-files (pre-commit is available either as a system package in Debian/Ubuntu or from a python package manager) . It could in principle be placed in a CI script, but it sometimes detects false positives (e.g. abbreviated variable names), so it is better to have a human eyes to cross-check.
False positives can be listed in _typos.toml so that they are ignored by the spell checker.

- pre-commit basic config: remove trailing white spaces, ...
- typos: try to fix spell check errors
@cburstedde
Copy link
Owner

Thanks! If I run on Debian (bookworm) I get this:

pre-commit run --all-files
->

[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
An error has occurred: InvalidManifestError: 
==> File /media/sda7_crypt/helpor/.cache/pre-commit/repo7pvo0f4b/.pre-commit-hooks.yaml
==> At Hook(id='check-added-large-files')
==> At key: stages
==> At index 0
=====> Expected one of commit, commit-msg, manual, merge-commit, post-checkout, post-commit, post-merge, post-rewrite, prepare-commit-msg, push but got: 'pre-commit'
Check the log at /media/sda7_crypt/helpor/.cache/pre-commit/pre-commit.log

@pkestene
Copy link
Contributor Author

pkestene commented Oct 2, 2025

I've just a ubuntu 24.04 at hand, and on my side when I run the command, everything is fine

 pkestene@home [fix-minors-typos → origin] ~/install/p4est/github/p4est % pre-commit run --all-files
check yaml...............................................................Passed
fix end of files.........................................................Passed
trim trailing whitespace.................................................Passed
check for added large files..............................................Passed
typos....................................................................Passed

I'm using pre-commit from the package manager, i.e. version 3.6.2 (no special python environment).

Also pre-commit itself is just a python script; which version of python are you using (from the system or third party like conda or like) ?

Can you just look at log to see what's wrong on your machine ?

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 this pull request may close these issues.

2 participants