PyCQA / flake8-bugbear

A plugin for Flake8 finding likely bugs and design problems in your program. Contains warnings that don't belong in pyflakes and pycodestyle.
MIT License
1.06k stars 104 forks source link

B109: Documentation/error message is wrong about the violation scope #408

Closed stefan6419846 closed 1 year ago

stefan6419846 commented 1 year ago

I find the current wording confusing when just reading the error description of B109 for evaluation.

Example:

import functools

@functools.lru_cache(maxsize=1)
def get_value():
    return 42

Given

B019: Use of functools.lru_cache or functools.cache on methods can lead to memory leaks. The cache may retain instance references, preventing garbage collection.

the above example should report a violation, as get_value() is a method. Judging from the code and #250, standalone methods do not fall into the scope of B019, thus the current description is misleading.

JelleZijlstra commented 1 year ago

get_value() isn't a method, it's a function. Methods exist in classes.

stefan6419846 commented 1 year ago

Okay, than this seems to be a vocabulary issue/different terminology than I am used to - I have never really considered making a difference about the term "method" and "function".