add warning for deprecated stages values in `default_stages` by asottile · Pull Request #3313 · pre-commit/pre-commit

@asottile

@asottile

@asottile asottile deleted the default-stages-warning branch

October 1, 2024 00:02

@DimitriPapadopoulos

I get this warning in CI:

top-level default_stages uses deprecated stage names (commit, push) which will be removed in a future version.  run: `pre-commit migrate-config` to automatically fix this.
Screen capture of pre-commit.ci

default_stages

Yet running pre-commit migrate-config in my repository doesn't have any effect:

$ pre-commit migrate-config
Configuration is already migrated.
$ 

@asottile

I get this warning in CI:

top-level default_stages uses deprecated stage names (commit, push) which will be removed in a future version.  run: `pre-commit migrate-config` to automatically fix this.

Screen capture of pre-commit.ci
Yet running pre-commit migrate-config in my repository doesn't have any effect:

$ pre-commit migrate-config
Configuration is already migrated.
$ 

obviously you're not using a new enough pre-commit version

@DimitriPapadopoulos

$ pre-commit --version
pre-commit 4.0.1
$ 

Could pre-commit.ci be using newer code than the latest released version of pre-commit?

@asottile

@DimitriPapadopoulos

@asottile

works for me

$ pre-commit migrate-config
Configuration has been migrated.
$ git diff
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index dd04f38..2835f59 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -3,7 +3,7 @@ ci:
   autoupdate_commit_msg: "chore: update pre-commit hooks"
   autofix_commit_msg: "style: pre-commit fixes"
   autofix_prs: false
-default_stages: [commit, push]
+default_stages: [pre-commit, pre-push]
 default_language_version:
   python: python3
 repos:

@DimitriPapadopoulos

It works on my home computer.
$ grep default_stages .pre-commit-config.yaml 
default_stages: [commit, push]
$ 
$ pipx install pre-commit
  installed package pre-commit 4.0.1, installed using Python 3.10.12
  These apps are now globally available
    - pre-commit
done! ✨ 🌟 ✨
$ 
$ pre-commit --version
pre-commit 4.0.1
$ 
$ pre-commit migrate-config
Configuration has been migrated.
$ 
$ grep default_stages .pre-commit-config.yaml 
default_stages: [pre-commit, pre-push]
$ 

I'll retry on my computer at work tomorrow, and let you know. Either I did something wrong, or this an effect of a Linux kernel or system issue that breaks my workstation in very strange ways since it was upgraded from Ubuntu 22.04 to Ubuntu 24.04.

@asottile

almost certainly it was an old version of pre-commit

@DimitriPapadopoulos

I don't think it is an old version (pre-commit installed with pipx just like at home). Rather, my workstation is plagued by mysterious I/O problems since the Ubuntu 24.04 upgrade, see for example prefix-dev/rattler-build#1045 (comment).

@asottile

I don't necessarily trust pipx to do what you want personally

@DimitriPapadopoulos

My workstation has been reinstalled by IT. I cannot reproduce the issue any more. Sorry about the noise.