-
-
Notifications
You must be signed in to change notification settings - Fork 309
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
flake8
fails if sys.stdout
is an io.StringIO
object
#1419
Comments
if you're monkeypatching I'd suggest using an |
This error is encountered when using flake8 under pytest:
Pinning flake8 to
|
We also ran into this when trying to put flake8 behind a language server for editor integration. And I think Anthony meant to suggest using |
thanks -- fixed! I'm currently working on a revamped public api which will return (file, position, code, message) tuples directly which should hopefully make these unsupported hacks unnecessary |
@asottile, where does this say what should be done by users of |
check the linked issues |
Please describe how you installed Flake8
The exact, unmodified output of `flake8 --bug-report` (click this line to show)
{
"dependencies": [],
"platform": {
"python_implementation": "CPython",
"python_version": "3.8.10",
"system": "Linux"
},
"plugins": [
{
"is_local": false,
"plugin": "mccabe",
"version": "0.6.1"
},
{
"is_local": false,
"plugin": "pycodestyle",
"version": "2.8.0"
},
{
"is_local": false,
"plugin": "pyflakes",
"version": "2.4.0"
}
],
"version": "4.0.1"
}
Please describe the problem or feature
There seems to be a problem with this line:
flake8/src/flake8/formatting/base.py
Line 187 in ecee230
The Python documentation (https://docs.python.org/3.8/library/sys.html#sys.stdout) warns that
sys.stdout
might end up being anio.StringIO
object, which does not have abuffer
attribute, and I have found a case where this happens in practice.If this is a bug report, please explain with examples (and example code) what you expected to happen and what actually happened.
I wanted to use pycodestyle_magic together with
flake8
in a Jupyter notebook. So the first code cell is:and the second:
The result is:
I replaced the previously mentioned line 187 with the following four lines:
and that fixed the problem for me.
The text was updated successfully, but these errors were encountered: