Skip to content

Commit 5b9edd0

Browse files
committedMar 31, 2021
clean up lru_cache in compat
1 parent 358ae85 commit 5b9edd0

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed
 

‎src/flake8/_compat.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
"""Expose backports in a single place."""
22
import sys
3-
from functools import lru_cache
43

54
if sys.version_info >= (3, 8): # pragma: no cover (PY38+)
65
import importlib.metadata as importlib_metadata
76
else: # pragma: no cover (<PY38)
87
import importlib_metadata
98

10-
__all__ = ("lru_cache", "importlib_metadata")
9+
__all__ = ("importlib_metadata",)

‎src/flake8/style_guide.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import contextlib
55
import copy
66
import enum
7+
import functools
78
import itertools
89
import linecache
910
import logging
@@ -20,7 +21,6 @@
2021
from flake8 import defaults
2122
from flake8 import statistics
2223
from flake8 import utils
23-
from flake8._compat import lru_cache
2424
from flake8.formatting import base as base_formatter
2525

2626
__all__ = ("StyleGuide",)
@@ -49,7 +49,7 @@ class Decision(enum.Enum):
4949
Selected = "selected error"
5050

5151

52-
@lru_cache(maxsize=512)
52+
@functools.lru_cache(maxsize=512)
5353
def find_noqa(physical_line): # type: (str) -> Optional[Match[str]]
5454
return defaults.NOQA_INLINE_REGEXP.search(physical_line)
5555

@@ -374,7 +374,7 @@ def populate_style_guides_with(self, options):
374374
filename=filename, extend_ignore_with=violations
375375
)
376376

377-
@lru_cache(maxsize=None)
377+
@functools.lru_cache(maxsize=None)
378378
def style_guide_for(self, filename): # type: (str) -> StyleGuide
379379
"""Find the StyleGuide for the filename in particular."""
380380
guides = sorted(

‎src/flake8/utils.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""Utility methods for flake8."""
22
import collections
33
import fnmatch as _fnmatch
4+
import functools
45
import inspect
56
import io
67
import logging
@@ -21,7 +22,6 @@
2122
from typing import Union
2223

2324
from flake8 import exceptions
24-
from flake8._compat import lru_cache
2525

2626
if False: # `typing.TYPE_CHECKING` was introduced in 3.5.2
2727
from flake8.plugins.manager import Plugin
@@ -209,7 +209,7 @@ def _stdin_get_value_py3(): # type: () -> str
209209
return stdin_value.decode("utf-8")
210210

211211

212-
@lru_cache(maxsize=1)
212+
@functools.lru_cache(maxsize=1)
213213
def stdin_get_value(): # type: () -> str
214214
"""Get and cache it so plugins can use it."""
215215
return _stdin_get_value_py3()

0 commit comments

Comments
 (0)