mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-13 08:04:18 +00:00
Merge branch 'pep8-stdin-fix' into 'master'
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 See merge request !44
This commit is contained in:
commit
d5e3987a9c
1 changed files with 14 additions and 0 deletions
|
|
@ -1,7 +1,9 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
import errno
|
import errno
|
||||||
|
import io
|
||||||
import platform
|
import platform
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
import pep8
|
import pep8
|
||||||
|
|
@ -293,3 +295,15 @@ def get_python_version():
|
||||||
except AttributeError: # Python 2.5
|
except AttributeError: # Python 2.5
|
||||||
impl = ''
|
impl = ''
|
||||||
return '%s%s on %s' % (impl, platform.python_version(), platform.system())
|
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