-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
functools-cache-decorating-method
checker
- Loading branch information
1 parent
7a9234f
commit 6fdba83
Showing
6 changed files
with
97 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
"""Tests for functools-cache-decorating-method""" | ||
# 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 cache | ||
from functools import cache as aliased_cache | ||
|
||
|
||
@cache | ||
def my_func(param): | ||
return param + 1 | ||
|
||
|
||
class MyClassWithMethods: | ||
@cache | ||
@staticmethod | ||
def my_func(param): | ||
return param + 1 | ||
|
||
@cache | ||
@classmethod | ||
def my_func(cls, param): | ||
return param + 1 | ||
|
||
@cache # [functools-cache-decorating-method] | ||
def my_func(self, param): | ||
return param + 1 | ||
|
||
@functools.cache # [functools-cache-decorating-method] | ||
def my_func(self, param): | ||
return param + 1 | ||
|
||
@aliased_functools.cache # [functools-cache-decorating-method] | ||
def my_func(self, param): | ||
return param + 1 | ||
|
||
@aliased_cache # [functools-cache-decorating-method] | ||
def my_func(self, param): | ||
return param + 1 | ||
|
||
# Check double decorating to check robustness of checker itself | ||
@aliased_cache # [functools-cache-decorating-method] | ||
@aliased_cache # [functools-cache-decorating-method] | ||
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,2 @@ | ||
[testoptions] | ||
min_pyver = 3.9 |
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,6 @@ | ||
functools-cache-decorating-method:27:5:27:10:MyClassWithMethods.my_func:'cache' will keep all method args alive indefinitely, including 'self':INFERENCE | ||
functools-cache-decorating-method:31:5:31:20:MyClassWithMethods.my_func:'cache' will keep all method args alive indefinitely, including 'self':INFERENCE | ||
functools-cache-decorating-method:35:5:35:28:MyClassWithMethods.my_func:'cache' will keep all method args alive indefinitely, including 'self':INFERENCE | ||
functools-cache-decorating-method:39:5:39:18:MyClassWithMethods.my_func:'cache' will keep all method args alive indefinitely, including 'self':INFERENCE | ||
functools-cache-decorating-method:44:5:44:18:MyClassWithMethods.my_func:'cache' will keep all method args alive indefinitely, including 'self':INFERENCE | ||
functools-cache-decorating-method:45:5:45:18:MyClassWithMethods.my_func:'cache' will keep all method args alive indefinitely, including 'self':INFERENCE |