Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False positive for B019 #236

Closed
nmrtv opened this issue Mar 21, 2022 · 2 comments · Fixed by #237
Closed

False positive for B019 #236

nmrtv opened this issue Mar 21, 2022 · 2 comments · Fixed by #237

Comments

@nmrtv
Copy link

nmrtv commented Mar 21, 2022

After the latest update, there are false positives for B019 on regular methods:
image

@jpy-git
Copy link
Contributor

jpy-git commented Mar 21, 2022

The lint is working correctly:

# Remaining methods should emit B019
@functools.cache
def cached_method(self, y):
...
@cache
def another_cached_method(self, y):
...
@functools.cache()
def called_cached_method(self, y):
...
@cache()
def another_called_cached_method(self, y):
...
@functools.lru_cache
def lru_cached_method(self, y):
...
@lru_cache
def another_lru_cached_method(self, y):
...
@functools.lru_cache()
def called_lru_cached_method(self, y):
...
@lru_cache()
def another_called_lru_cached_method(self, y):
...

Here's a great video on why this is advised against 😄

IMO the lint message is very misleading though. it says class methods meaning methods on a class (which is pretty much the definition of a method) and probably leads to confusion with classmethods which have a very specific meaning. Will update the lint description to make it clearer 👍

(p.s. in the future it's best to copy code into issues rather than a screenshot as it saves having to re-type it out when triaging)

@nmrtv
Copy link
Author

nmrtv commented Mar 21, 2022

Actually, I don't have this problem in my code, because the class itself is a singleton. Thank you for description clarification. At least it will not be confusing why it's ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants