-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix else and add type annotation Any
- Loading branch information
1 parent
ea3930a
commit f6f87c4
Showing
1 changed file
with
4 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
from typing import Callable | ||
from typing import Callable, Any | ||
|
||
|
||
def cache(func: Callable) -> Callable: | ||
cache_dict = {} | ||
|
||
def wrapper(*args: Callable) -> Callable: | ||
def wrapper(*args) -> Any: | ||
if args not in cache_dict: | ||
cache_dict[args] = func(*args) | ||
print("Calculating new result") | ||
else: | ||
print("Getting from cache") | ||
return cache_dict[args] | ||
print("Getting from cache") | ||
return cache_dict[args] | ||
|
||
return wrapper |