Skip to content

Commit 45c47e6

Browse files
faizan-mcopybara-github
authored andcommitted
Remove functools.wraps for unbound methods to support inspect.signature
PiperOrigin-RevId: 485685579
1 parent 6b90fdb commit 45c47e6

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sonnet/src/utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,9 @@ def _decorate_bound_method(*args, **kwargs):
7777
argspec = inspect.getfullargspec(f)
7878
if argspec.args and argspec.args[0] == "self":
7979

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

0 commit comments

Comments
 (0)