mirror of
https://github.com/PyCQA/flake8.git
synced 2026-04-10 14:54:17 +00:00
clean up _stdin_get_value_py3
This commit is contained in:
parent
4d57a20ffd
commit
018dbcd69a
1 changed files with 3 additions and 7 deletions
|
|
@ -197,7 +197,9 @@ def normalize_path(path, parent=os.curdir):
|
||||||
return path.rstrip(separator + alternate_separator)
|
return path.rstrip(separator + alternate_separator)
|
||||||
|
|
||||||
|
|
||||||
def _stdin_get_value_py3(): # type: () -> str
|
@functools.lru_cache(maxsize=1)
|
||||||
|
def stdin_get_value(): # type: () -> str
|
||||||
|
"""Get and cache it so plugins can use it."""
|
||||||
stdin_value = sys.stdin.buffer.read()
|
stdin_value = sys.stdin.buffer.read()
|
||||||
fd = io.BytesIO(stdin_value)
|
fd = io.BytesIO(stdin_value)
|
||||||
try:
|
try:
|
||||||
|
|
@ -208,12 +210,6 @@ def _stdin_get_value_py3(): # type: () -> str
|
||||||
return stdin_value.decode("utf-8")
|
return stdin_value.decode("utf-8")
|
||||||
|
|
||||||
|
|
||||||
@functools.lru_cache(maxsize=1)
|
|
||||||
def stdin_get_value(): # type: () -> str
|
|
||||||
"""Get and cache it so plugins can use it."""
|
|
||||||
return _stdin_get_value_py3()
|
|
||||||
|
|
||||||
|
|
||||||
def stdin_get_lines(): # type: () -> List[str]
|
def stdin_get_lines(): # type: () -> List[str]
|
||||||
"""Return lines of stdin split according to file splitting."""
|
"""Return lines of stdin split according to file splitting."""
|
||||||
return list(io.StringIO(stdin_get_value()))
|
return list(io.StringIO(stdin_get_value()))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue