Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/zipp/_functools.py: 64%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1import collections
2import functools
5# from jaraco.functools 4.0.2
6def save_method_args(method):
7 """
8 Wrap a method such that when it is called, the args and kwargs are
9 saved on the method.
10 """
11 args_and_kwargs = collections.namedtuple('args_and_kwargs', 'args kwargs') # noqa: PYI024
13 @functools.wraps(method)
14 def wrapper(self, /, *args, **kwargs):
15 attr_name = '_saved_' + method.__name__
16 attr = args_and_kwargs(args, kwargs)
17 setattr(self, attr_name, attr)
18 return method(self, *args, **kwargs)
20 return wrapper