Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git hook flake8: error: input not specified

Flake8's pre-commit hook for git raises flake8: error: input not specified whenever I do git commit.

The hook file is identical to the official example :

#!/usr/bin/python
import sys
from flake8.run import git_hook

COMPLEXITY = 10
STRICT = False

if __name__ == '__main__':
    sys.exit(git_hook(complexity=COMPLEXITY, strict=STRICT, ignore='E501'))
like image 917
adamsmith Avatar asked Jun 24 '26 16:06

adamsmith


2 Answers

Yes, this is due to a bug in flake8 2.1.0. To work around this, create an empty setup.cfg or tox.ini file in your project directory. I just created a bug ticket for this: https://bitbucket.org/tarek/flake8/issue/133/git_hook-broken-when-setupcfg-and-toxini

like image 121
Kevin Avatar answered Jun 27 '26 05:06

Kevin


There was a similar bug on a previous flake8 version (issue 68, fixed by commit 8fe9bfb)

But a very recent version of flake8 might have re-introduced that bug again (tweet, 6:02 PM - 20 Nov 13):

I'm not sure what happened to flake8 after update.
My old trusty pre-commit hook now returns, "flake8: error: input not specified".


The OP dlutxx reports in the comments:

until they fixed this bug, I'll just append the source directory to sys.argv within the pre-commit file.
Ugly, but [it] works.

like image 24
VonC Avatar answered Jun 27 '26 04:06

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!