diff options
| author | Ian Cordasco <graffatcolmingov@gmail.com> | 2015-12-04 00:13:28 -0600 |
|---|---|---|
| committer | Ian Cordasco <graffatcolmingov@gmail.com> | 2015-12-04 00:13:28 -0600 |
| commit | 41393c9b6de513ea169b61c175b71018e8a12336 (patch) | |
| tree | 0a4316c464d064da78c62d96036bdae977ed5c60 | |
| parent | 54a81c0595f97d39a2624e77ba781b4ab167f660 (diff) | |
| download | flake8-pep8-stdin-fix.tar.gz | |
Cache stdin for Flake8 pluginspep8-stdin-fix
Currently plugins (e.g., flake8-docstrings) are struggling to support
users passing data in on stdin (e.g., cat file.py | flake8 -). Until
pep8 fixes this itself, we can monkey-patch its `stdin_get_value`
function to handle the caching for us.
Closes #105
| -rw-r--r-- | flake8/engine.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/flake8/engine.py b/flake8/engine.py index d8345ad..e90940e 100644 --- a/flake8/engine.py +++ b/flake8/engine.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- import errno +import io import platform import re +import sys import warnings import pep8 @@ -293,3 +295,15 @@ def get_python_version(): except AttributeError: # Python 2.5 impl = '' return '%s%s on %s' % (impl, platform.python_version(), platform.system()) + + +def make_stdin_get_value(): + value = pep8.stdin_get_value() + if sys.version_info < (3, 0): + stdin = io.BytesIO(value) + else: + stdin = io.StringIO(value) + return stdin.getvalue + + +pep8.stdin_get_value = make_stdin_get_value() |
