From: Harmon Date: Tue, 6 Apr 2021 16:02:00 +0000 (-0500) Subject: Properly wrap methods with pagination and payload decorators X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=bd71027548ea5bb957ce7281a7b55a043f4dd468;p=tweepy.git Properly wrap methods with pagination and payload decorators --- diff --git a/tweepy/api.py b/tweepy/api.py index 5ea831f..f065181 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -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