Black always makes pre-commit fail #85
lahdjirayhan
started this conversation in
General
Replies: 1 comment
-
@lahdjirayhan yeah I've come across this and was wondering what it was - not too bad though, because the commit goes through the second time just like you described. On a slightly tangential note, the pre commit hook takes a few seconds to run, and might feel a little strange for someone who hasn't experienced using it before. I think we should add a note in the CONTRIBUTING file mentioning this so people are aware of what's causing the delay |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
If black reformats your staged code, pre-commit will detect that the staged file is changed and will think the hook is failed.
This is because pre-commit won't proceed to commit if the staged file is modified (which is what happens if black reformats your code).
From the issue linked below:
Reference for more of information:
Personally what I've done is if I found black modifying a file and fail the pre-commit hook, I would just re-commit again. It usually just works the second time as black wouldn't modify anything.
While this is annoying, I'm not sure we can do much about it. If you know something that can improve this experience, you are very welcome to chime in your suggestions.
Beta Was this translation helpful? Give feedback.
All reactions