def wrapped(backend, *args, **kwargs): try: sig = inspect.signature(f) except AttributeError: spec = inspect.getargspec(f) params = spec[0] else: params = sig.parameters if 'backend' in params: kwargs.setdefault('backend', backend) with substituted_trueskill(backend=backend): return f(*args, **kwargs)
def wrapped(backend, *args, **kwargs): if 'backend' in inspect.getargspec(f)[0]: kwargs['backend'] = kwargs.get('backend', backend) with substituted_trueskill(backend=backend): return f(*args, **kwargs)