diff --git a/doc/data/messages/f/functools-cache-decorating-method/bad.py b/doc/data/messages/f/functools-cache-decorating-method/bad.py new file mode 100644 index 00000000000..8d013c676e0 --- /dev/null +++ b/doc/data/messages/f/functools-cache-decorating-method/bad.py @@ -0,0 +1,7 @@ +import functools + + +class MyClassWithMethods: + @functools.cache # [functools-cache-decorating-method] + def my_func(self, param): + return param + 1 diff --git a/doc/data/messages/f/functools-cache-decorating-method/good.py b/doc/data/messages/f/functools-cache-decorating-method/good.py new file mode 100644 index 00000000000..ea07354aa45 --- /dev/null +++ b/doc/data/messages/f/functools-cache-decorating-method/good.py @@ -0,0 +1,3 @@ +class MyClassWithMethods: + def my_func(self, param): + return param + 1 diff --git a/pylint/checkers/stdlib.py b/pylint/checkers/stdlib.py index c9e97664518..da3ba700265 100644 --- a/pylint/checkers/stdlib.py +++ b/pylint/checkers/stdlib.py @@ -569,7 +569,10 @@ def visit_boolop(self, node: nodes.BoolOp) -> None: for value in node.values: self._check_datetime(value) - @utils.check_messages("lru-cache-decorating-method") + @utils.check_messages( + "lru-cache-decorating-method", + "functools-cache-decorating-method", + ) def visit_functiondef(self, node: nodes.FunctionDef) -> None: if node.decorators and isinstance(node.parent, nodes.ClassDef): self._check_lru_cache_decorators(node.decorators)