-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pre-commit: "Expected one of commit, commit-msg, manual, ..." since 23.11.0 #4065
Comments
According to https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md#320---2023-03-17 the "pre-commit" value should be allowed since 3.2.0, but I think I have 3.5.0 installed. Looking in site-packages/pre_commit/clientlib.py, I see:
That looks correct |
The |
Does executing |
Yes, it does :-) Interesting. I need to check what happens there. Is the update of |
@Wolfcast: Your error message says Try updating python3 -m pip install --upgrade pre-commit |
@davidculley Yeah I deleted my comment before your reply :) The global pre-commit was up to date but not the one in my venv. |
IMO this solution is preferable #4041 The current version of Debian uses pre-commit 3.0.4, so it would be nice for it to work on that. |
Ubuntu 22.04 LTS (jammy) has pre-commit 2.17.0 https://packages.ubuntu.com/jammy/pre-commit |
What am I missing @andrewmwilson @marcindulak, why can't Debian/Ubuntu users not execute |
In hobby projects it's possible to pull packages from the internet, but in enterprises someone with required permissions would need to modify CI systems and developer machine images to include that change. Additionally, a custom installation of pre-commit brings additional packages (see example below), and those would create a liability by extending the need of scanning them for vulnerabilities and patching, while those tasks are normally delegated to the operating system vendor
|
Still getting the error after a |
For $ poetry remove pre-commit
Updating dependencies
Resolving dependencies... (0.5s)
Package operations: 0 installs, 0 updates, 6 removals
• Removing cfgv (3.4.0)
• Removing identify (2.5.33)
• Removing nodeenv (1.8.0)
• Removing pre-commit (2.21.0)
• Removing pyyaml (6.0.1)
• Removing setuptools (69.0.2)
Writing lock file Then add it: $ poetry add pre-commit --group dev
Using version ^3.6.0 for pre-commit
Updating dependencies
Resolving dependencies... (0.8s)
Package operations: 6 installs, 0 updates, 0 removals
• Installing setuptools (69.0.2)
• Installing cfgv (3.4.0)
• Installing identify (2.5.33)
• Installing nodeenv (1.8.0)
• Installing pyyaml (6.0.1)
• Installing pre-commit (3.6.0)
Writing lock file |
Note for anyone currently broken by this, you can try using psf/black-pre-commit-mirror instead. This never received the change in #3940, so should still work with older versions of pre-commit. It'll also make black like 2x faster :-) |
Thanks for the explanation @marcindulak and sorry for the late answer. I haven't thus far found myself in such a situation, therefore I wasn't aware of the issues you describe. Now I can better put myself in your shoes, thank you. |
This fixes the issue described in this bug report in black: psf/black#4065
Recent commit 0bd340d ("pre-commit autoupdate") bumped the isort version to 6.0.0. Subsequently, I started running into: ... $ SKIP=flake8,isort pre-commit run An error has occurred: InvalidManifestError: ==> File /home/vries/.cache/pre-commit/repommstqefj/.pre-commit-hooks.yaml ==> At Hook(id='isort') ==> 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 /home/vries/.cache/pre-commit/pre-commit.log ... I found a similar PR [1], that explains that using pre-commit as a stage (as isort 6.0.0 does) is supported starting pre-commit 3.2.0. Add minimum_pre_commit_version 3.2.0 in .pre-commit-config.yaml, as suggested in the PR. After adding this, I get a more helpful message: ... $ SKIP=flake8,isort pre-commit run An error has occurred: InvalidConfigError: ==> File .pre-commit-config.yaml ==> At Config() ==> At key: minimum_pre_commit_version =====> pre-commit version 3.2.0 is required but version 2.17.0 is installed. \ Perhaps run `pip install --upgrade pre-commit`. Check the log at /home/vries/.cache/pre-commit/pre-commit.log ... and after doing so which upgrades pre-commit to version 4.1.0, as well as re-installing pre-commit using: ... $ pre-commit uninstall $ pre-commit install ... I have a functional setup again. Interestingly, since pre-commit 4.1.0 runs in a python 3.11 environment, I no longer need to skip flake8 and isort, as I needed to previously when the system python 3.6 was used. Approved-By: Simon Marchi <[email protected]> [1] psf/black#4065
Describe the bug
When the pre-commit hook is installed and I commit, I get:
To Reproduce
The resulting error is:
Expected behavior
A pre-commit fixes
c.py
Environment
Additional context
#3940
The text was updated successfully, but these errors were encountered: