Skip to content
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/black is getting in the way too much #6877

Closed
blueyed opened this issue Mar 8, 2020 · 7 comments
Closed

pre-commit/black is getting in the way too much #6877

blueyed opened this issue Mar 8, 2020 · 7 comments

Comments

@blueyed
Copy link
Contributor

blueyed commented Mar 8, 2020

It is annoying to get interrupted with something like:

% gc
[WARNING] Unstaged files detected.
[INFO] Stashing unstaged files to /home/user/.cache/pre-commit/patch1583628686.
black....................................................................Failed
- hook id: black
- files were modified by this hook
[20+ lines deleted]
[INFO] Restored changes from /home/user/.cache/pre-commit/patch1583628686.

to see that black did turn it into something less readable (since it does
not recognize "exploding commas" with function calls):

-    result.stdout.fnmatch_lines([
-        'E       assert False',
-        '*- Captured stdout call -*',
-        'hello',
-    ])
+    result.stdout.fnmatch_lines(
+        ["E       assert False", "*- Captured stdout call -*", "hello",]
+    )

Therefore I think it would be more sensible to either exclude black from the
pre-commit config altogether, or not to recommend installing pre-commit in the first place.

I think it is fine to enforce checks on CI, but that could/should be limited to
flake8 etc only, and black could be run then in the release process.

Black is meant to have consistent output for things being committed, but it does not help if you have to add # fmt: {on,off} (after being interrupted), or just accept that it is less readable etc.
I.e. in the second case it certainly causes code to be less readable / and more affected to diff churn (when tests get hardened/changed with regard to their output).

@blueyed

This comment has been minimized.

blueyed added a commit to blueyed/pytest that referenced this issue Mar 8, 2020
As far as I know `pre-commit` does not have a switch to skip/exclude a "hook",
and it should not cause CI to fail - flake8 is enough for this.

Ref: pytest-dev#6877
@hugovk
Copy link
Member

hugovk commented Mar 8, 2020

I think this magic comma will be fixed in psf/black#1288, but you could ask there to double check.

@RonnyPfannschmidt
Copy link
Member

i consider black a integral part of keeping certain review overheads low,
i'm not going to agree with removing it

@blueyed
Copy link
Contributor Author

blueyed commented Mar 8, 2020

@hugovk the issue is older already (psf/black#1010).
And even if it was fixed, it might still get in the way (with new issues etc).

(FWIW I agree with using black in general, and often use it manually. I've disabled pre-commit myself for now (making git-commit snappy again), and will see how that goes - since there is a distinct "lint" job on CI where black gets run, it's easy to spot/fix anything missed then. And yes, I am aware of --no-verify already)

@nicoddemus
Copy link
Member

Definitely 👎 on removing black.

blueyed added a commit to blueyed/pytest that referenced this issue Mar 9, 2020
Started with not enforcing pre-commit [1], but then also merged "short"
and "long" version.

1: pytest-dev#6877
blueyed added a commit to blueyed/pytest that referenced this issue Mar 17, 2020
Started with not enforcing pre-commit [1], but then also merged "short"
and "long" version.

1: pytest-dev#6877
@blueyed
Copy link
Contributor Author

blueyed commented Mar 27, 2020

@nicoddemus sorry, you've missed the point (again) - this was not about removing black, but only not making it mandatory via pre-commit etc. See the refs above.

@nicoddemus
Copy link
Member

Sure, sorry, but either way you are definitely free to uninstall pre-commit and run tox -e linting manually, but we should not recommend that in general, as people often get it wrong.

blueyed added a commit to blueyed/pytest that referenced this issue Jul 13, 2020
Started with not enforcing pre-commit [1], but then also merged "short"
and "long" version.

1: pytest-dev#6877
blueyed added a commit to blueyed/pytest that referenced this issue Oct 13, 2020
Started with not enforcing pre-commit [1], but then also merged "short"
and "long" version.

1: pytest-dev#6877
blueyed added a commit to blueyed/pytest that referenced this issue Oct 13, 2020
Started with not enforcing pre-commit [1], but then also merged "short"
and "long" version.

1: pytest-dev#6877
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants