Properly wrap methods with pagination and payload decorators
authorHarmon <Harmon758@gmail.com>
Tue, 6 Apr 2021 16:02:00 +0000 (11:02 -0500)
committerHarmon <Harmon758@gmail.com>
Tue, 6 Apr 2021 16:05:03 +0000 (11:05 -0500)
tweepy/api.py

index 5ea831f57d90fd77f647c4f09136a00045d122cb..f065181b03e7a33fa409a6c67d82e04045e7a6ba 100644 (file)
@@ -2,6 +2,7 @@
 # Copyright 2009-2021 Joshua Roesslein
 # See LICENSE for details.
 
+import functools
 import imghdr
 import logging
 import mimetypes
@@ -25,14 +26,18 @@ log = logging.getLogger(__name__)
 
 def pagination(mode):
     def decorator(method):
-        method.pagination_mode = mode
-        return method
+        @functools.wraps(method)
+        def wrapper(*args, **kwargs):
+            return method(*args, **kwargs)
+        wrapper.pagination_mode = mode
+        return wrapper
     return decorator
 
 
 def payload(payload_type, **payload_kwargs):
     payload_list = payload_kwargs.get('list', False)
     def decorator(method):
+        @functools.wraps(method)
         def wrapper(*args, **kwargs):
             kwargs['payload_list'] = payload_list
             kwargs['payload_type'] = payload_type