black as pre-commit hook always fails my commits

(author of pre-commit here)

the framework intentionally does not provide a way to auto-commit modifications. Here’s a few issues which have asked for such:

  • pre-commit/pre-commit#806
  • pre-commit/pre-commit#747

A comment from one of those issues:

pre-commit itself will never touch the staging area. These are good ways to silently break commits. In my mind this is one of the worst things that [other frameworks do and suggest] — hooks are very frequently not perfect and magically changing what’s being committed should not be taken lightly.

That said, if you would like to foot gun, your hook can call git add -u and pre-commit won’t know any better 🙂 a sketch of that (untested, discouraged)

  - id: yapf
    entry: bash -c 'yapf "$@"; git add -u' --

(note: using bash will potentially reduce portability)

Another comment notes

Fortunately, git add -u && !! is pretty easy to run if you’re ok firing from the hip 🙂

Leave a Comment

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş