Add initial pre-commit configuration#1280
Conversation
| # - repo: https://github.com/tox-dev/pyproject-fmt | ||
| # rev: v2.11.1 | ||
| # hooks: | ||
| # - id: pyproject-fmt | ||
| # name: format pyproject.toml |
There was a problem hiding this comment.
This hook would impose a particular opinionated style for pyproject.toml. It does help keep the file organized, but this one is fine to skip if you don't like the style.
| # - repo: https://github.com/hukkin/mdformat | ||
| # rev: 1.0.0 | ||
| # hooks: | ||
| # - id: mdformat | ||
| # name: format .md files | ||
| # additional_dependencies: | ||
| # - mdformat-footnote | ||
| # - mdformat-gfm | ||
| # - mdformat-gfm-alerts | ||
| # - mdformat-ruff |
There was a problem hiding this comment.
mdformat autoformats Markdown files, and the additional dependencies are for GitHub flavored Markdown.
| ignore-words-list = """ | ||
| fo, | ||
| inout, | ||
| tha, | ||
| thi""" |
There was a problem hiding this comment.
This is just a subset of the possible misspellings that codespell is finding.
|
Thanks so much for taking the time to put this together! I'll look over your suggestions, give myself some time to wrap my head around all of this, and probably get back to you with some questions or comments. I kind of thinking to do one big set of formatting fixups, packaged up as a squashed 'commit of doom", which will let me put it in a .git-blame-ignore-revs file. That might keep our 'git blame' annotations from getting swamped with a ton of mostly whitespace changes. I'd probably want to avoid anything that would automatically change pyproject.toml, at least to start with -- we're now using pdm to manage our project dependencies, and every change to pyproject.toml should also come with a rebuilt version of pdm.lock, to keep the checksums in sync (but maybe this is already accounted for in the pre-commit hook?) Is this stuff strictly on the Github side, or is there a way for developers to get this feedback immediately in their dev environment, before pushing to github? |
That's a good idea! I was thinking one large PR for the autoformatting changes that only require a cursory code review, and then smaller pull requests for changes that need a person to look them over.
Good question! I don't know how well pyproject-fmt works with pdm, but I've had no problems using it with uv.
I knew I forgot something! 😅 The changes can be applied to all files with It's also possible to do |
This PR adds an initial configuration for pre-commit in
.pre-commit-config.yaml. The purpose of using pre-commit is to perform quality checks and enact automated fixes for new contributions and throughout the repository.pre-commit.ciwebsite and click on the button near the top to "Sign In With GitHub". That should lead you through the process of activating pre-commit as a check on pull requests.Thus far, I've added a bunch of pre-commit hooks from various sources. I'm enabling hooks that are passing without changes, and commenting out hooks that would require changes to implement. Some of these hooks would make changes to a wide variety of files, like the one for removing trailing whitespace. It'd probably work best to apply those changes in multiple pull requests. The autoformatting hooks could likely be lumped together into large pull requests since they change style but don't change content, but a few of the hooks will require careful code review. For
ruff checkspecifically, it would make sense to do this in multiple smaller pull requests (e.g., subpackage by subpackage).I hope this helps!