mirror of
https://github.com/nvbn/thefuck.git
synced 2025-01-19 12:24:29 +00:00
Merge pull request #400 from alessio/fix-memoize
Fix misinterpretation of the disabled flag
This commit is contained in:
commit
fe91008a9c
@ -23,11 +23,16 @@ def memoize(fn):
|
|||||||
|
|
||||||
@wraps(fn)
|
@wraps(fn)
|
||||||
def wrapper(*args, **kwargs):
|
def wrapper(*args, **kwargs):
|
||||||
|
if not memoize.disabled:
|
||||||
key = pickle.dumps((args, kwargs))
|
key = pickle.dumps((args, kwargs))
|
||||||
if key not in memo or memoize.disabled:
|
if key not in memo:
|
||||||
memo[key] = fn(*args, **kwargs)
|
memo[key] = fn(*args, **kwargs)
|
||||||
|
value = memo[key]
|
||||||
|
else:
|
||||||
|
# Memoize is disabled, call the function
|
||||||
|
value = fn(*args, **kwargs)
|
||||||
|
|
||||||
return memo[key]
|
return value
|
||||||
|
|
||||||
return wrapper
|
return wrapper
|
||||||
memoize.disabled = False
|
memoize.disabled = False
|
||||||
|
Loading…
x
Reference in New Issue
Block a user