-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Monkeypatching stdout leads to AttributeError in flake8 #9217
Comments
pytest is not the patcher in this case -- pytest-flake8 is |
I did search the codebase for pytest-flake8 and the term |
Seems the issue was already reported at tholo/pytest-flake8#81, but Google failed me (an exact search for the error message did not find the issue). |
@jaraco https://github.com/tholo/pytest-flake8/blob/9db176caba1738df680bf574619b7f0f2dd85ac4/pytest_flake8.py#L119 is the part that it uses monkey-patching. The reality is that
This almost makes me want to distribute a pytest plugin for flake8 from flake8 |
I think that would make quite a few people quite a bit happier. I'd certainly back it, and would help in any way I could... |
imo running flake8 inside pytest is an antipattern (it certainly is going to be much much slower) so it probably isn't going to happen |
I should have emphasized "almost" I know flake8 in |
with the advent of pre-commit my personal opinion is that given the available tooling the test runner by now is absolutely the wrong place for quick code checks |
While I agree pytest is the worst place for this, there are systems that are limited and out of a developers control sometimes and the only way to be sure any edit to the code is compliant is via pytest-pyflakes or pytest-flake8. I don't think the need is abated by local machine tooling, especially as GitHub tries to push people into the cloud for development. I hate it, but there's reasons why people need this |
* See pytest-dev/pytest#9217 * Somehow we are pulling in pytest-flake8 or something else that patches stdout * This seems to be the standard / only real solution currently * Can only be seen when flake8 reports errors...
* See pytest-dev/pytest#9217 * Somehow we are pulling in pytest-flake8 or something else that patches stdout * This seems to be the standard / only real solution currently * Can only be seen when flake8 reports errors...
The `pytest-flake8` plugin broke with a recent update of `flake8`. According to this thread: pytest-dev/pytest#9217 (comment) running these kinds of checks within `pytest` is an anti-pattern and should be avoided. So I've moved `black`, `mypy`, and `flake8` checks away from their pytest plugins.
In PyCQA/flake8#1419, a user reported an issue with the most recent release of flake8 in which an AttributeError will occur if
sys.stdout
is patched with an object without abuffer
attribute.This issue is triggered when
pytest
patchessys.stdout
and thepytest-flake8
plugin is used.According to the flake8 issue, it's the responsibility of this project to address the issue as monkeypatcher of sys.stdout.
The text was updated successfully, but these errors were encountered: