-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: cachetools.__wrapped__ attribute typing for cached functions #13701
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
Open
markparonyan
wants to merge
14
commits into
python:main
Choose a base branch
from
markparonyan:fix-cachetools-wrapped-attribute
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+35
−13
Open
Changes from 6 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
bd49b3a
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 1735ae7
Merge branch 'main' into fix-cachetools-wrapped-attribute
markparonyan 245b8b2
Fix cachetools.__wrapped__ attribute typing for cached functions
markparonyan dac4b8b
tests: __wrapped__ attribute in cached functions
markparonyan c2331cd
Merge branch 'fix-cachetools-wrapped-attribute' of github.com:markpar…
markparonyan 4311410
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 0948449
Merge branch 'main' into fix-cachetools-wrapped-attribute
markparonyan 70a5914
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 6a0f88c
refactor: mv test to cachetools/@tests
markparonyan 32ff683
Merge branch 'fix-cachetools-wrapped-attribute' of github.com:markpar…
markparonyan 7a38dea
fix: use functools._Wrapped directly
markparonyan 017b454
fix(tests): mv cachetools test to test_cases
markparonyan 5a4c8c3
Merge branch 'fix-cachetools-wrapped-attribute' of github.com:markpar…
markparonyan f339345
fix(tests): rename to check_cachetools_wrapped
markparonyan 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 hidden or 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 hidden or 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 |
---|---|---|
@@ -1,19 +1,24 @@ | ||
from _typeshed import IdentityFunction | ||
from collections.abc import Callable, Sequence | ||
from typing import TypeVar | ||
from typing import TypeVar, overload | ||
from typing_extensions import deprecated | ||
|
||
from . import _Cached | ||
|
||
__all__ = ("fifo_cache", "lfu_cache", "lru_cache", "mru_cache", "rr_cache", "ttl_cache") | ||
_T = TypeVar("_T") | ||
_S = TypeVar("_S") | ||
|
||
def fifo_cache(maxsize: float | None = 128, typed: bool = False) -> IdentityFunction: ... | ||
def lfu_cache(maxsize: float | None = 128, typed: bool = False) -> IdentityFunction: ... | ||
def lru_cache(maxsize: float | None = 128, typed: bool = False) -> IdentityFunction: ... | ||
def fifo_cache(maxsize: float | None = 128, typed: bool = False) -> Callable[[Callable[..., _T]], _Cached[_T]]: ... | ||
def lfu_cache(maxsize: float | None = 128, typed: bool = False) -> Callable[[Callable[..., _T]], _Cached[_T]]: ... | ||
def lru_cache(maxsize: float | None = 128, typed: bool = False) -> Callable[[Callable[..., _T]], _Cached[_T]]: ... | ||
@deprecated("@mru_cache is deprecated") | ||
def mru_cache(maxsize: float | None = 128, typed: bool = False) -> IdentityFunction: ... | ||
def mru_cache(maxsize: float | None = 128, typed: bool = False) -> Callable[[Callable[..., _T]], _Cached[_T]]: ... | ||
@overload | ||
def rr_cache(maxsize: float | None = 128, *, typed: bool = False) -> Callable[[Callable[..., _T]], _Cached[_T]]: ... | ||
@overload | ||
def rr_cache( | ||
maxsize: float | None = 128, choice: Callable[[Sequence[_T]], _T] | None = ..., typed: bool = False | ||
) -> IdentityFunction: ... | ||
maxsize: float | None, choice: Callable[[Sequence[_S]], _S], typed: bool = False | ||
) -> Callable[[Callable[..., _T]], _Cached[_T]]: ... | ||
def ttl_cache( | ||
maxsize: float | None = 128, ttl: float = 600, timer: Callable[[], float] = ..., typed: bool = False | ||
) -> IdentityFunction: ... | ||
) -> Callable[[Callable[..., _T]], _Cached[_T]]: ... |
This file contains hidden or 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,14 @@ | ||
from typing import Any | ||
|
||
from cachetools import LRUCache, cached | ||
Check failure on line 3 in tests/cachetools_wrapped_test.py
|
||
|
||
cache: LRUCache[str, Any] = LRUCache(maxsize=128) | ||
|
||
|
||
@cached(cache) | ||
def example_function(x: int) -> str: | ||
return str(x) | ||
|
||
|
||
original_function = example_function.__wrapped__ | ||
result = original_function(42) |
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.
Uh oh!
There was an error while loading. Please reload this page.