-
-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixing integration with pytest-flake8 #1422
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
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.