Derived from the flake8-bugbear linter.
What it does#
Checks for uses of the
decorators on methods.
Why is this bad?#
functools.cache decorators on methods
can lead to memory leaks, as the global cache will retain a reference to
the instance, preventing it from being garbage collected.
Instead, refactor the method to depend only on its arguments and not on the
instance of the class, or use the
@lru_cache decorator on a function
outside of the class.