Skip to content

Commit 0f047a1

Browse files
committed
improve error messages about custom key makers
1 parent 758b08d commit 0f047a1

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

memoization/memoization.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ def calculate_performance(employee):
110110
custom_key_maker_info.defaults != user_function_info.defaults or \
111111
custom_key_maker_info.kwonlydefaults != user_function_info.kwonlydefaults:
112112
warnings.warn('Expected custom_key_maker to have the same signature as the function being cached. '
113-
'Call memoization.suppress_warnings() to remove this message.', SyntaxWarning)
113+
'Call memoization.suppress_warnings() before using @cached to remove this message.',
114+
SyntaxWarning)
114115

115116
def custom_key_maker_wrapper(args, kwargs):
116117
return custom_key_maker(*args, **kwargs)
@@ -127,6 +128,7 @@ def custom_key_maker_wrapper(args, kwargs):
127128
def suppress_warnings(should_warn=False):
128129
"""
129130
Disable/Enable warnings when @cached is used
131+
Must be called before using @cached
130132
131133
:param should_warn: Whether warnings should be shown (False by default)
132134
"""

0 commit comments

Comments
 (0)