Skip to content

Commit

Permalink
Add .fn attributes to cache wrappers in caching.py (#88)
Browse files Browse the repository at this point in the history
This will enable `qcore.get_original_fn` (and thence pyanalyze) to understand the signatures of these functions.
  • Loading branch information
JelleZijlstra authored Apr 18, 2022
1 parent b21f73b commit 530d0a4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions qcore/caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ def wrapper(*args, **kwargs):
return value

wrapper.clear = cache.clear
wrapper.fn = fn

return wrapper

Expand Down Expand Up @@ -313,6 +314,7 @@ def new_fun(self, *args, **kwargs):

# just so unit tests can check that this is cleaned up correctly
new_fun.__cached_per_instance_cache__ = cache
new_fun.fn = fun
return new_fun

return cache_fun
Expand Down Expand Up @@ -379,6 +381,7 @@ def clear_cache():

new_fun.__cache = {}
new_fun.clear_cache = clear_cache
new_fun.fn = fun
return new_fun


Expand Down Expand Up @@ -442,6 +445,7 @@ def dirty(*args, **kwargs):
new_fun.__cache_times = {}
new_fun.clear_cache = clear_cache
new_fun.dirty = dirty
new_fun.fn = fun
return new_fun

return cache_fun

0 comments on commit 530d0a4

Please sign in to comment.