-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Only emit
lru-cache-decorating-method
when maxsize
is None
(
#6181) Co-authored-by: Jacob Walls <[email protected]> Co-authored-by: Pierre Sassoulas <[email protected]>
- Loading branch information
1 parent
7024743
commit 0741313
Showing
8 changed files
with
109 additions
and
156 deletions.
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.