diff options
| author | Anthony Sottile <asottile@umich.edu> | 2021-03-29 18:09:37 -0700 |
|---|---|---|
| committer | Anthony Sottile <asottile@umich.edu> | 2021-03-30 17:37:13 -0700 |
| commit | 5b9edd04eeb184922f38f28dd682317d56372592 (patch) | |
| tree | b32b649d36b390e52e3b076634281bf529ed5e95 /src | |
| parent | 358ae85120b5336f6abf574688b1f7290b3c8cc4 (diff) | |
| download | flake8-5b9edd04eeb184922f38f28dd682317d56372592.tar.gz | |
clean up lru_cache in compat
Diffstat (limited to 'src')
| -rw-r--r-- | src/flake8/_compat.py | 3 | ||||
| -rw-r--r-- | src/flake8/style_guide.py | 6 | ||||
| -rw-r--r-- | src/flake8/utils.py | 4 |
3 files changed, 6 insertions, 7 deletions
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 (<PY38) import importlib_metadata -__all__ = ("lru_cache", "importlib_metadata") +__all__ = ("importlib_metadata",) diff --git a/src/flake8/style_guide.py b/src/flake8/style_guide.py index df2a036..915021d 100644 --- a/src/flake8/style_guide.py +++ b/src/flake8/style_guide.py @@ -4,6 +4,7 @@ import collections import contextlib import copy import enum +import functools import itertools import linecache import logging @@ -20,7 +21,6 @@ from typing import Union from flake8 import defaults from flake8 import statistics from flake8 import utils -from flake8._compat import lru_cache from flake8.formatting import base as base_formatter __all__ = ("StyleGuide",) @@ -49,7 +49,7 @@ class Decision(enum.Enum): Selected = "selected error" -@lru_cache(maxsize=512) +@functools.lru_cache(maxsize=512) def find_noqa(physical_line): # type: (str) -> 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() |
