Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This supersedes #240 and addresses #237
Based on discussions on Slack I suspect this may not be mergeable, but wanted to discuss anyway.
My priorities when implementing this were roughly prioritised as:
placate flake8
commits. (git commit --no-verify
is right there if it is needed, but my strong opinion is that hooks need to introduce friction to be meaningful, otherwise they are like compiler and deprecation warnings and will be ignored until they do cause friction).pre-commit-config.yaml
.pre-commit-config.yaml
way of doing things, because I usually get confused when I try to commit and it rewrites my stuff)Things it checks:
git diff-index
's built-in functionality)git diff-index output
)black
flake8
mypy
check-migrations
make html
eslint
All of these apart from the first two require creating a copy of the repo in a temporary directory to be able to remove any files that the linters shouldn't check without affecting any open file handles in the working directory. (This also helps avoid polluting the reflog.) If creating that fails, these tests are skipped. The directory is removed before the hook finishes, including if it is aborted with Ctrl+C.
This requires a non-zero amount of machinery, but significantly less than used by
.pre-commit-config.yaml
, and is what I would consider the minimal required to satisfactorily run linters in a pre-commit hook (in a way I would be willing to use in my workflow).