From 018dbcd69a45b8686cbe63f5e8ce1ba13198f9d7 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 29 Mar 2021 18:16:31 -0700 Subject: [PATCH] clean up _stdin_get_value_py3 --- src/flake8/utils.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/flake8/utils.py b/src/flake8/utils.py index 6bf0b49..5db1d22 100644 --- a/src/flake8/utils.py +++ b/src/flake8/utils.py @@ -197,7 +197,9 @@ def normalize_path(path, parent=os.curdir): 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() fd = io.BytesIO(stdin_value) try: @@ -208,12 +210,6 @@ def _stdin_get_value_py3(): # type: () -> str 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] """Return lines of stdin split according to file splitting.""" return list(io.StringIO(stdin_get_value()))