Skip to content

Commit

Permalink
Remove functools.wraps for unbound methods to support inspect.signature
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 485685579
  • Loading branch information
faizan-m authored and Copybara-Service committed Nov 2, 2022
1 parent 6b90fdb commit 45c47e6
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sonnet/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ def _decorate_bound_method(*args, **kwargs):
argspec = inspect.getfullargspec(f)
if argspec.args and argspec.args[0] == "self":

@functools.wraps(f)
# TODO(b/123870292): Bound methods with multiple decorators can be
# detected as unbound too, which breaks tf.function usage.
# Attempt migrating to wrapt instead of using this custom approach.
def _decorate_unbound_method(self, *args, **kwargs):
bound_method = f.__get__(self, self.__class__) # pytype: disable=attribute-error
return decorator_fn(bound_method, self, args, kwargs)
Expand Down

0 comments on commit 45c47e6

Please sign in to comment.