gin/config.py
def _ensure_wrappability(fn):
  """Make sure `fn` can be wrapped cleanly by functools.wraps."""
  # Handle "wrapped_descriptor" and "method-wrapper" types.
  if isinstance(fn, (type(object.__init__), type(object.__call__))):
    # pylint: disable=unnecessary-lambda
    wrappable_fn = lambda *args, **kwargs: fn(*args, **kwargs)
    wrappable_fn.__name__ = fn.__name__
    wrappable_fn.__doc__ = fn.__doc__
    wrappable_fn.__module__ = ''  # These types have no __module__, sigh.
    wrappable_fn.__wrapped__ = fn
    return wrappable_fn

  # Otherwise we're good to go...
  return fn
def _ensure_wrappability(fn):
  """Make sure `fn` can be wrapped cleanly by functools.wraps."""
  # Handle "wrapped_descriptor" and "method-wrapper" types.
  if isinstance(fn, (type(object.__init__), type(object.__call__))):
    # pylint: disable=unnecessary-lambda
    wrappable_fn = lambda *args, **kwargs: fn(*args, **kwargs)
    wrappable_fn.__name__ = fn.__name__
    wrappable_fn.__doc__ = fn.__doc__
    wrappable_fn.__module__ = ''  # These types have no __module__, sigh.
    wrappable_fn.__wrapped__ = fn
    return wrappable_fn

  # Otherwise we're good to go...
  return fn
def _ensure_wrappability ( fn ) : # Handle "wrapped_descriptor" and "method-wrapper" types. if isinstance ( fn , ( type ( object . __init__ ) , type ( object . __call__ ) ) ) : # pylint: disable=unnecessary-lambda wrappable_fn = lambda * args , * * kwargs : fn ( * args , * * kwargs ) wrappable_fn . __name__ = fn . __name__ wrappable_fn . __doc__ = fn . __doc__ wrappable_fn . __module__ = '' # These types have no __module__, sigh. wrappable_fn . __wrapped__ = fn return wrappable_fn # Otherwise we're good to go... return fn
Make sure `fn` can be wrapped cleanly by functools.wraps.
Make sure fn can be wrapped cleanly by functools . wraps .