fix memory leak caused by lru_cache of a method

This commit is contained in:
Anthony Sottile 2022-03-20 17:04:30 -04:00
parent 94ed800b2a
commit befc26f78e

View file

@ -240,6 +240,10 @@ class StyleGuideManager:
) )
) )
self.style_guide_for = functools.lru_cache(maxsize=None)(
self._style_guide_for
)
def populate_style_guides_with( def populate_style_guides_with(
self, options: argparse.Namespace self, options: argparse.Namespace
) -> Generator["StyleGuide", None, None]: ) -> Generator["StyleGuide", None, None]:
@ -256,8 +260,7 @@ class StyleGuideManager:
filename=filename, extend_ignore_with=violations filename=filename, extend_ignore_with=violations
) )
@functools.lru_cache(maxsize=None) def _style_guide_for(self, filename: str) -> "StyleGuide":
def style_guide_for(self, filename: str) -> "StyleGuide":
"""Find the StyleGuide for the filename in particular.""" """Find the StyleGuide for the filename in particular."""
guides = sorted( guides = sorted(
(g for g in self.style_guides if g.applies_to(filename)), (g for g in self.style_guides if g.applies_to(filename)),