I am working on a decorator library that is modifying keyword arguments of a function, and the library is doing what I want it to do, but it's very inconvenient that while debugging, whenever the user function is called, the debugger has to pass through the decorator library code.
I implemented the decorator as a class (see https://github.com/mapa17/configfy/blob/master/configfy/decorator.py)
and the user function is wrapped by the following library code:
def __call__(self, *args, **kwargs):
if self.needs_wrapping:
self.needs_wrapping = False
self.func = args[0]
functools.update_wrapper(self, self.func)
self.kwargs = self.__get_kw_args(self.func)
# If config file is specified in decorator, new kwargs can be precalculated!
if self.config is not None:
self.new_kwargs = self._get_new_kwargs()
return self
# Use precalculated kwargs if available
if self.new_kwargs is None:
new_kwargs = self._get_new_kwargs()
else:
new_kwargs = self.new_kwargs
# Overwrite them with any passed arguments; passed arguments have priority!
new_kwargs.update(kwargs)
# Call target (aka user) function with altered kwargs
return self.func(*args, **new_kwargs)
So is it possible to somehow skip this library code when debugging?