mirror of
https://github.com/PyCQA/flake8.git
synced 2026-03-30 02:46:52 +00:00
Cache stdin for Flake8 plugins
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
This commit is contained in:
parent
54a81c0595
commit
41393c9b6d
1 changed files with 14 additions and 0 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue