git hook does not stop git commit of bad code
Please describe how you installed Flake8
Example:
$ pip3 install --upgrade flake8
Requirement already up-to-date: flake8 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Requirement already up-to-date: pyflakes<1.6.0,>=1.5.0 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from flake8)
Requirement already up-to-date: pycodestyle<2.4.0,>=2.0.0 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from flake8)
Requirement already up-to-date: mccabe<0.7.0,>=0.6.0 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from flake8)
$ flake8 --version
3.3.0 (flake8-blind-except: 0.1.1, flake8-docstrings: 1.1.0, pydocstyle: 2.0.0, flake8_commas._base: 0.4.3, mccabe: 0.6.1, pycodestyle: 2.3.1, pyflakes: 1.5.0) CPython 3.6.0 on Darwin
$ flake8 --bug-report
{
"dependencies": [
{
"dependency": "setuptools",
"version": "35.0.2"
}
],
"platform": {
"python_implementation": "CPython",
"python_version": "3.6.0",
"system": "Darwin"
},
"plugins": [
{
"plugin": "flake8-blind-except",
"version": "0.1.1"
},
{
"plugin": "flake8-docstrings",
"version": "1.1.0, pydocstyle: 2.0.0"
},
{
"plugin": "flake8_commas._base",
"version": "0.4.3"
},
{
"plugin": "mccabe",
"version": "0.6.1"
},
{
"plugin": "pycodestyle",
"version": "2.3.1"
},
{
"plugin": "pyflakes",
"version": "1.5.0"
}
],
"version": "3.3.0"
}
Please describe the problem or feature
The git pre-commit hook fails to prevent bad commits where Python code fails the flake8 checks.
If this is a bug report, please explain with examples (and example code) what you expected to happen and what actually happened.
Working example:
Create an example which fails flake8 checks,
$ echo "import os#bad spaceing" > silly.py
$ flake8 silly.py
silly.py:1:1: F401 'os' imported but unused
silly.py:1:1: D100 Missing docstring in public module
silly.py:1:10: E261 at least two spaces before inline comment
silly.py:1:10: E262 inline comment should start with '# '
Attempt to commit the bad file,
$ git add silly.py
$ git commit silly.py -m "This should be stopped by the hook" ; echo "Return code $?"
silly.py:1:1: F401 'os' imported but unused
silly.py:1:1: D100 Missing docstring in public module
silly.py:1:10: E261 at least two spaces before inline comment
silly.py:1:10: E262 inline comment should start with '# '
[master 2332038] This should be stopped by the hook
1 file changed, 1 insertion(+)
create mode 100644 silly.py
Return code 0
Here the expected result was the flake8 hook should have returned non-zero and aborted the git commit.
Instead while we see the issues found by flake8, the commit happens.