Skip to content

Commit

Permalink
confine pre-commit to stages (#3940)
Browse files Browse the repository at this point in the history
See https://pre-commit.com/#confining-hooks-to-run-at-certain-stages

> If you are authoring a tool, it is usually a good idea to provide an appropriate `stages` property. For example a reasonable setting for a linter or code formatter would be `stages: [pre-commit, pre-merge-commit, pre-push, manual]`.

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
  • Loading branch information
davidculley and JelleZijlstra committed Oct 27, 2023
1 parent 53c4278 commit 7686989
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .pre-commit-hooks.yaml
Expand Up @@ -4,6 +4,7 @@
name: black
description: "Black: The uncompromising Python code formatter"
entry: black
stages: [pre-commit, pre-merge-commit, pre-push, manual]

This comment has been minimized.

Copy link
@xavierhardy

xavierhardy Nov 16, 2023

I'm now getting this error when running pre-commit autoupdate

Updating https://github.com/pre-commit/pre-commit-hooks ... 
[INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks.
updating v4.4.0 -> v4.5.0.
Updating https://github.com/psf/black ... 
[INFO] Initializing environment for https://github.com/psf/black.
==> File /home/user/.cache/pre-commit/repo14w82uxt/.pre-commit-hooks.yaml
==> At Hook(id='black')
==> 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'
language: python
minimum_pre_commit_version: 2.9.2
require_serial: true
Expand All @@ -13,6 +14,7 @@
description:
"Black: The uncompromising Python code formatter (with Jupyter Notebook support)"
entry: black
stages: [pre-commit, pre-merge-commit, pre-push, manual]
language: python
minimum_pre_commit_version: 2.9.2
require_serial: true
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Expand Up @@ -45,6 +45,9 @@

<!-- For example, Docker, GitHub Actions, pre-commit, editors -->

- Black's pre-commit integration will now run only on git hooks appropriate for a code
formatter (#3940)

### Documentation

<!-- Major changes to documentation and policies. Small docs changes
Expand Down

0 comments on commit 7686989

Please sign in to comment.