-
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
DOC: cleanup pre-commit instructions following #2430 #2481
Conversation
I don't think this change warrants a mention in the changelog. I can add one if required but I'd be content with a "skip news" label. |
Correct me if I'm wrong but if you don't specify that |
@zsol I believe this was previously discussed in #2430. Here's the key comment therein
|
If I can give my 2 cents: It's true that specifying Python3 is no longer necessary, as there's no longer any risk of Example: $ cat t.py
if a := 3 > 0: print(a)
$ vim .pre-commit-config.yaml
$ cat .pre-commit-config.yaml
repos:
- repo: https://github.com/psf/black
rev: 21.9b0
hooks:
- id: black
$ pre-commit run black --all-files
black....................................................................Failed
- hook id: black
- exit code: 123
error: cannot format t.py: cannot use --safe with this file; failed to parse source file. AST error message: invalid syntax (<unknown>, line 1)
Oh no! 💥 💔 💥
1 file failed to reformat.
$ vim .pre-commit-config.yaml
$ cat .pre-commit-config.yaml
repos:
- repo: https://github.com/psf/black
rev: 21.9b0
hooks:
- id: black
language_version: python3.8
$ pre-commit run black --all-files
black....................................................................Failed
- hook id: black
- files were modified by this hook
reformatted t.py
All done! ✨ 🍰 ✨
1 file reformatted. So arguably it's still good advice to specify a language version. Perhaps the docs could just be modified to show:
? |
Wouldn't it be redundant with the target-version parameter ? |
Just setting $ cat .pre-commit-config.yaml
repos:
- repo: https://github.com/psf/black
rev: 21.9b0
hooks:
- id: black
args: ['-t', 'py38']
$ pre-commit run black -a
black....................................................................Failed
- hook id: black
- exit code: 123
error: cannot format t.py: cannot use --safe with this file; failed to parse source file. AST error message: invalid syntax (<unknown>, line 1)
Oh no! 💥 💔 💥
1 file failed to reformat. |
Interesting. In retrospect, I think I never realised this because the only large project I've used black via pre-commit with has 3.6 as a target, and So the correct recommendation would actually be to merge align edit: following my first edit, I think the reason that |
I've not looked much into |
Alright I updated the PR to reflect this discussion. |
Thanks! |
Description
I believe this was forgotten in #2430
Checklist - did you ...