Skip to content

Commit

Permalink
Fix classmethod wrapping (#5826)
Browse files Browse the repository at this point in the history
  • Loading branch information
theacodes authored Aug 21, 2018
1 parent d6fe5e1 commit b19fc95
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pubsub/google/cloud/pubsub_v1/_gapic.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def wrap(wrapped_fx):
# Similarly, for instance methods, we need to send self.api rather
# than self, since that is where the actual methods were declared.
instance_method = True

# If this is a bound method it's a classmethod.
self = getattr(wrapped_fx, '__self__', None)
if issubclass(type(self), type):
instance_method = False
Expand All @@ -41,8 +43,9 @@ def wrap(wrapped_fx):
if instance_method:
fx = lambda self, *a, **kw: wrapped_fx(self.api, *a, **kw) # noqa
return functools.wraps(wrapped_fx)(fx)
fx = lambda self, *a, **kw: wrapped_fx(*a, **kw) # noqa
return functools.wraps(wrapped_fx)(fx)

fx = lambda *a, **kw: wrapped_fx(*a, **kw) # noqa
return staticmethod(functools.wraps(wrapped_fx)(fx))

def actual_decorator(cls):
# Reflectively iterate over most of the methods on the source class
Expand Down

0 comments on commit b19fc95

Please sign in to comment.