From 5b9edd04eeb184922f38f28dd682317d56372592 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Mon, 29 Mar 2021 18:09:37 -0700 Subject: clean up lru_cache in compat --- src/flake8/_compat.py | 3 +-- src/flake8/style_guide.py | 6 +++--- src/flake8/utils.py | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/flake8/_compat.py b/src/flake8/_compat.py index 640f2bd..18809e2 100644 --- a/src/flake8/_compat.py +++ b/src/flake8/_compat.py @@ -1,10 +1,9 @@ """Expose backports in a single place.""" import sys -from functools import lru_cache if sys.version_info >= (3, 8): # pragma: no cover (PY38+) import importlib.metadata as importlib_metadata else: # pragma: no cover ( Optional[Match[str]] return defaults.NOQA_INLINE_REGEXP.search(physical_line) @@ -374,7 +374,7 @@ class StyleGuideManager: filename=filename, extend_ignore_with=violations ) - @lru_cache(maxsize=None) + @functools.lru_cache(maxsize=None) def style_guide_for(self, filename): # type: (str) -> StyleGuide """Find the StyleGuide for the filename in particular.""" guides = sorted( diff --git a/src/flake8/utils.py b/src/flake8/utils.py index cd1b036..074cf0b 100644 --- a/src/flake8/utils.py +++ b/src/flake8/utils.py @@ -1,6 +1,7 @@ """Utility methods for flake8.""" import collections import fnmatch as _fnmatch +import functools import inspect import io import logging @@ -21,7 +22,6 @@ from typing import Tuple from typing import Union from flake8 import exceptions -from flake8._compat import lru_cache if False: # `typing.TYPE_CHECKING` was introduced in 3.5.2 from flake8.plugins.manager import Plugin @@ -209,7 +209,7 @@ def _stdin_get_value_py3(): # type: () -> str return stdin_value.decode("utf-8") -@lru_cache(maxsize=1) +@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() -- cgit v1.2.1