alexcouper / captainhook

Git hook scripts

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

flake8 not reporting errors

alexcouper opened this issue · comments

The redirection of stdout and stderr in the flake8 checker is not working as expected.

with change_folder(temp_folder):
        flake8_style = get_style_guide(config_file=DEFAULT_CONFIG)
        out, err = StringIO(), StringIO()
        with redirected(out, err):
            flake8_style.check_files(py_files)

Without the redirection, I see that flake8 is correctly detecting errors in files.
With the redirection it appears that nothing is actually written to the StringIO objects.

Requires some investigation.

why not use the exitcode to determine the error?

$ flake8 ; echo $?
./test.py:6:2: E225 missing whitespace around operator
./test.py:14:5: F841 local variable 'x' is assigned to but never used
./test.py:14:8: E225 missing whitespace around operator
1
$ flake8 ; echo $?
0