Repository navigation
Fixing integration with pytest-flake8 - #1422
IljaOrlovs wants to merge 5 commits into
Conversation
|
if you monkeypatch, that is at your own risk -- use |
|
@asottile this is pytest output capture, i believe this should reopen /fix |
|
@RonnyPfannschmidt it is not, pytest output capture does this correctly (I know because it was my first major contribution to pytest!) def test():
sys.stdout.buffer.write(b'hi\n') |
|
But what (kind of) solution would both solve the problem that |
|
@asottile i see, ill crosscheck pytest flake8 once I recover from my cold as it seems to trigger this |
|
|
it is not "poorly monkeypatched" - even the official Python 3 documentation warns about this kind of situation:
flake8 in this case should just check if sys.stdout has the buffer property and act accordingly.. |
|
the docs warn that people may do this wrong yes -- that doesn't mean we should support unsupported things |
Hello,
The recent change to flake8's _stdoutWriteHook ( 7a353d2 ) breaks integration with some wrappers that attempt to capture flake8's sys.stdout output (e.g. pytest-flake8 does @ https://github.com/tholo/pytest-flake8/blob/master/pytest_flake8.py#L119 ), as it is uncommon for the capture code to emulate the .buffer attribute.
This PR modifies the stdout.write logic to be similar to sys.displayhook's ( https://docs.python.org/3/library/sys.html#displayhook ) that should keep everyone happy, hopefully - both Windows and integration people.