-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Only emit lru-cache-decorating-method
when maxsize
is None
#6181
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6219a42
Only emit ``lru-cache-decorating-method`` when ``maxsize`` is ``None``
DanielNoord 5a40fb3
Remove useless warniung
DanielNoord adbb142
Update comment
DanielNoord b1ff0de
Update wording
DanielNoord ef7f3e7
Fix typo
jacobtylerwalls cbc5e08
Rename to ``cache-max-size-none``
DanielNoord 9539728
Merge branch 'lru-cache' of https://github.com/DanielNoord/pylint int…
DanielNoord 5154338
Update pylint/message/message_definition_store.py
DanielNoord File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
"""Tests for cache-max-size-none""" | ||
# pylint: disable=no-self-use, missing-function-docstring, reimported, too-few-public-methods | ||
# pylint: disable=missing-class-docstring, function-redefined | ||
|
||
import functools | ||
import functools as aliased_functools | ||
from functools import lru_cache | ||
from functools import lru_cache as aliased_cache | ||
|
||
|
||
@lru_cache | ||
def my_func(param): | ||
return param + 1 | ||
|
||
|
||
class MyClassWithMethods: | ||
@lru_cache() | ||
def my_func(self, param): | ||
return param + 1 | ||
|
||
@lru_cache(1) | ||
def my_func(self, param): | ||
return param + 1 | ||
|
||
@lru_cache(None) # [cache-max-size-none] | ||
def my_func(self, param): | ||
return param + 1 | ||
|
||
@functools.lru_cache(None) # [cache-max-size-none] | ||
def my_func(self, param): | ||
return param + 1 | ||
|
||
@aliased_functools.lru_cache(None) # [cache-max-size-none] | ||
def my_func(self, param): | ||
return param + 1 | ||
|
||
@aliased_cache(None) # [cache-max-size-none] | ||
def my_func(self, param): | ||
return param + 1 | ||
|
||
# Check double decorating to check robustness of checker itself | ||
@aliased_cache(None) # [cache-max-size-none] | ||
@aliased_cache(None) # [cache-max-size-none] | ||
def my_func(self, param): | ||
return param + 1 | ||
|
||
|
||
class MyClassWithMethodsAndMaxSize: | ||
@lru_cache(maxsize=1) | ||
def my_func(self, param): | ||
return param + 1 | ||
|
||
@lru_cache(maxsize=1) | ||
def my_func(self, param): | ||
return param + 1 | ||
|
||
@lru_cache(typed=True) | ||
def my_func(self, param): | ||
return param + 1 | ||
|
||
@lru_cache(typed=True) | ||
def my_func(self, param): | ||
return param + 1 | ||
|
||
@lru_cache(typed=True, maxsize=1) | ||
def my_func(self, param): | ||
return param + 1 | ||
|
||
@lru_cache(typed=True, maxsize=1) | ||
def my_func(self, param): | ||
return param + 1 | ||
|
||
@lru_cache(typed=True, maxsize=None) # [cache-max-size-none] | ||
def my_func(self, param): | ||
return param + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
cache-max-size-none:25:5:25:20:MyClassWithMethods.my_func:'lru_cache(maxsize=None)' will keep all method args alive indefinitely, including 'self':INFERENCE | ||
cache-max-size-none:29:5:29:30:MyClassWithMethods.my_func:'lru_cache(maxsize=None)' will keep all method args alive indefinitely, including 'self':INFERENCE | ||
cache-max-size-none:33:5:33:38:MyClassWithMethods.my_func:'lru_cache(maxsize=None)' will keep all method args alive indefinitely, including 'self':INFERENCE | ||
cache-max-size-none:37:5:37:24:MyClassWithMethods.my_func:'lru_cache(maxsize=None)' will keep all method args alive indefinitely, including 'self':INFERENCE | ||
cache-max-size-none:42:5:42:24:MyClassWithMethods.my_func:'lru_cache(maxsize=None)' will keep all method args alive indefinitely, including 'self':INFERENCE | ||
cache-max-size-none:43:5:43:24:MyClassWithMethods.my_func:'lru_cache(maxsize=None)' will keep all method args alive indefinitely, including 'self':INFERENCE | ||
cache-max-size-none:73:5:73:40:MyClassWithMethodsAndMaxSize.my_func:'lru_cache(maxsize=None)' will keep all method args alive indefinitely, including 'self':INFERENCE |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maxsize
is spelled as one word in the argument. What aboutcache-maxsize-none
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we keep it like
max-size
we can potentially reuse later on for another function. But I'm fine with either!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't feel strongly. Happy to keep this way.