From 374b88bd323abb5637e44d9a97c5269016d56aa3 Mon Sep 17 00:00:00 2001 From: Harmon Date: Wed, 3 Feb 2021 01:57:56 -0600 Subject: [PATCH] Change path to positional argument for bind_api --- tweepy/api.py | 274 ++++++++++++++++------------------------------- tweepy/binder.py | 3 +- 2 files changed, 96 insertions(+), 181 deletions(-) diff --git a/tweepy/api.py b/tweepy/api.py index 9c0376e..44b7e37 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -78,8 +78,7 @@ class API: 'exclude_replies', 'include_entities' """ return bind_api( - self, 'GET', *args, - path='/statuses/home_timeline.json', + self, 'GET', '/statuses/home_timeline.json', *args, allowed_param=['count', 'since_id', 'max_id', 'trim_user', 'exclude_replies', 'include_entities'], require_auth=True, **kwargs @@ -95,8 +94,7 @@ class API: kwargs['map'] = kwargs.pop('map_') return bind_api( - self, 'GET', list_to_csv(id_), *args, - path='/statuses/lookup.json', + self, 'GET', '/statuses/lookup.json', list_to_csv(id_), *args, allowed_param=['id', 'include_entities', 'trim_user', 'map', 'include_ext_alt_text', 'include_card_uri'], require_auth=True, **kwargs @@ -111,8 +109,7 @@ class API: 'include_rts' """ return bind_api( - self, 'GET', *args, - path='/statuses/user_timeline.json', + self, 'GET', '/statuses/user_timeline.json', *args, allowed_param=['user_id', 'screen_name', 'since_id', 'count', 'max_id', 'trim_user', 'exclude_replies', 'include_rts'], **kwargs @@ -125,8 +122,7 @@ class API: :allowed_param: 'since_id', 'max_id', 'count' """ return bind_api( - self, 'GET', *args, - path='/statuses/mentions_timeline.json', + self, 'GET', '/statuses/mentions_timeline.json', *args, allowed_param=['since_id', 'max_id', 'count'], require_auth=True, **kwargs ) @@ -138,8 +134,7 @@ class API: :allowed_param: 'since_id', 'max_id', 'count' """ return bind_api( - self, 'GET', *args, - path='/statuses/retweets_of_me.json', + self, 'GET', '/statuses/retweets_of_me.json', *args, allowed_param=['since_id', 'max_id', 'count'], require_auth=True, **kwargs ) @@ -152,8 +147,7 @@ class API: 'include_card_uri' """ return bind_api( - self, 'GET', *args, - path='/statuses/show.json', + self, 'GET', '/statuses/show.json', *args, allowed_param=['id', 'trim_user', 'include_my_retweet', 'include_entities', 'include_ext_alt_text', 'include_card_uri'], **kwargs @@ -173,8 +167,7 @@ class API: kwargs['media_ids'] = list_to_csv(kwargs['media_ids']) return bind_api( - self, 'POST', *args, - path='/statuses/update.json', + self, 'POST', '/statuses/update.json', *args, allowed_param=['status', 'in_reply_to_status_id', 'auto_populate_reply_metadata', 'exclude_reply_user_ids', 'attachment_url', @@ -209,8 +202,7 @@ class API: kwargs.update({'headers': headers, 'post_data': post_data}) return bind_api( - self, 'POST', *args, - path='/media/upload.json', + self, 'POST', '/media/upload.json', *args, allowed_param=[], require_auth=True, upload_api=True, **kwargs @@ -226,8 +218,7 @@ class API: } return bind_api( - self, 'POST', *args, - path='/media/metadata/create.json', + self, 'POST', '/media/metadata/create.json', *args, allowed_param=[], require_auth=True, upload_api=True, **kwargs @@ -248,8 +239,7 @@ class API: kwargs.update({'headers': headers, 'post_data': post_data}) return bind_api( - self, 'POST', *args, - path='/statuses/update_with_media.json', + self, 'POST', '/statuses/update_with_media.json', *args, allowed_param=['status', 'possibly_sensitive', 'in_reply_to_status_id', 'in_reply_to_status_id_str', @@ -264,8 +254,7 @@ class API: :allowed_param: """ return bind_api( - self, 'POST', *args, - path=f'/statuses/destroy/{status_id}.json', + self, 'POST', f'/statuses/destroy/{status_id}.json', *args, require_auth=True, **kwargs ) @@ -275,8 +264,7 @@ class API: :allowed_param: """ return bind_api( - self, 'POST', *args, - path=f'/statuses/retweet/{status_id}.json', + self, 'POST', f'/statuses/retweet/{status_id}.json', *args, require_auth=True, **kwargs ) @@ -286,8 +274,7 @@ class API: :allowed_param: """ return bind_api( - self, 'POST', *args, - path=f'/statuses/unretweet/{status_id}.json', + self, 'POST', f'/statuses/unretweet/{status_id}.json', *args, require_auth=True, **kwargs ) @@ -297,8 +284,7 @@ class API: :allowed_param: 'count' """ return bind_api( - self, 'GET', *args, - path=f'/statuses/retweets/{status_id}.json', + self, 'GET', f'/statuses/retweets/{status_id}.json', *args, allowed_param=['count'], require_auth=True, **kwargs ) @@ -310,8 +296,7 @@ class API: :allowed_param: 'id', 'cursor', 'stringify_ids """ return bind_api( - self, 'GET', *args, - path='/statuses/retweeters/ids.json', + self, 'GET', '/statuses/retweeters/ids.json', *args, allowed_param=['id', 'cursor', 'stringify_ids'], **kwargs ) @@ -321,8 +306,7 @@ class API: :allowed_param: 'id', 'user_id', 'screen_name' """ return bind_api( - self, 'GET', *args, - path='/users/show.json', + self, 'GET', '/users/show.json', *args, allowed_param=['id', 'user_id', 'screen_name'], **kwargs ) @@ -334,8 +318,7 @@ class API: 'link_color', 'widget_type', 'dnt' """ return bind_api( - self, 'GET', *args, - path='/statuses/oembed.json', + self, 'GET', '/statuses/oembed.json', *args, allowed_param=['url', 'maxwidth', 'hide_media', 'hide_thread', 'omit_script', 'align', 'related', 'lang', 'theme', 'link_color', 'widget_type', 'dnt'], **kwargs @@ -348,9 +331,8 @@ class API: 'tweet_mode' """ return bind_api( - self, 'POST', list_to_csv(user_ids), list_to_csv(screen_names), - *args, - path='/users/lookup.json', + self, 'POST', '/users/lookup.json', list_to_csv(user_ids), + list_to_csv(screen_names), *args, allowed_param=['user_id', 'screen_name', 'include_entities', 'tweet_mode'], **kwargs ) @@ -366,8 +348,7 @@ class API: :allowed_param: 'q', 'count', 'page' """ return bind_api( - self, 'GET', *args, - path='/users/search.json', + self, 'GET', '/users/search.json', *args, require_auth=True, allowed_param=['q', 'count', 'page'], **kwargs ) @@ -378,8 +359,7 @@ class API: :allowed_param: 'id' """ return bind_api( - self, 'GET', *args, - path='/direct_messages/events/show.json', + self, 'GET', '/direct_messages/events/show.json', *args, allowed_param=['id'], require_auth=True, **kwargs ) @@ -391,8 +371,7 @@ class API: :allowed_param: 'count', 'cursor' """ return bind_api( - self, 'GET', *args, - path='/direct_messages/events/list.json', + self, 'GET', '/direct_messages/events/list.json', *args, allowed_param=['count', 'cursor'], require_auth=True, **kwargs ) @@ -427,8 +406,7 @@ class API: if ctas is not None: message_data['ctas'] = ctas return bind_api( - self, 'POST', - path='/direct_messages/events/new.json', + self, 'POST', '/direct_messages/events/new.json', require_auth=True, json_payload=json_payload, **kwargs ) @@ -438,8 +416,7 @@ class API: :allowed_param: 'id' """ return bind_api( - self, 'DELETE', *args, - path='/direct_messages/events/destroy.json', + self, 'DELETE', '/direct_messages/events/destroy.json', *args, allowed_param=['id'], require_auth=True, **kwargs ) @@ -450,8 +427,7 @@ class API: :allowed_param: 'id', 'user_id', 'screen_name', 'follow' """ return bind_api( - self, 'POST', *args, - path='/friendships/create.json', + self, 'POST', '/friendships/create.json', *args, allowed_param=['id', 'user_id', 'screen_name', 'follow'], require_auth=True, **kwargs ) @@ -462,8 +438,7 @@ class API: :allowed_param: 'id', 'user_id', 'screen_name' """ return bind_api( - self, 'POST', *args, - path='/friendships/destroy.json', + self, 'POST', '/friendships/destroy.json', *args, allowed_param=['id', 'user_id', 'screen_name'], require_auth=True, **kwargs ) @@ -475,8 +450,7 @@ class API: 'target_screen_name' """ return bind_api( - self, 'GET', *args, - path='/friendships/show.json', + self, 'GET', '/friendships/show.json', *args, allowed_param=['source_id', 'source_screen_name', 'target_id', 'target_screen_name'], **kwargs ) @@ -487,8 +461,8 @@ class API: :allowed_param: 'user_id', 'screen_name' """ return bind_api( - self, 'GET', list_to_csv(user_ids), list_to_csv(screen_names), - path='/friendships/lookup.json', + self, 'GET', '/friendships/lookup.json', list_to_csv(user_ids), + list_to_csv(screen_names), allowed_param=['user_id', 'screen_name'], require_auth=True, **kwargs ) @@ -500,8 +474,7 @@ class API: :allowed_param: 'id', 'user_id', 'screen_name', 'cursor' """ return bind_api( - self, 'GET', *args, - path='/friends/ids.json', + self, 'GET', '/friends/ids.json', *args, allowed_param=['id', 'user_id', 'screen_name', 'cursor'], **kwargs ) @@ -513,8 +486,7 @@ class API: 'skip_status', 'include_user_entities' """ return bind_api( - self, 'GET', *args, - path='/friends/list.json', + self, 'GET', '/friends/list.json', *args, allowed_param=['id', 'user_id', 'screen_name', 'cursor', 'count', 'skip_status', 'include_user_entities'], **kwargs ) @@ -526,8 +498,7 @@ class API: :allowed_param: 'cursor' """ return bind_api( - self, 'GET', *args, - path='/friendships/incoming.json', + self, 'GET', '/friendships/incoming.json', *args, allowed_param=['cursor'], **kwargs ) @@ -538,8 +509,7 @@ class API: :allowed_param: 'cursor' """ return bind_api( - self, 'GET', *args, - path='/friendships/outgoing.json', + self, 'GET', '/friendships/outgoing.json', *args, allowed_param=['cursor'], **kwargs ) @@ -550,8 +520,7 @@ class API: :allowed_param: 'id', 'user_id', 'screen_name', 'cursor', 'count' """ return bind_api( - self, 'GET', *args, - path='/followers/ids.json', + self, 'GET', '/followers/ids.json', *args, allowed_param=['id', 'user_id', 'screen_name', 'cursor', 'count'], **kwargs ) @@ -564,8 +533,7 @@ class API: 'skip_status', 'include_user_entities' """ return bind_api( - self, 'GET', *args, - path='/followers/list.json', + self, 'GET', '/followers/list.json', *args, allowed_param=['id', 'user_id', 'screen_name', 'cursor', 'count', 'skip_status', 'include_user_entities'], **kwargs ) @@ -574,8 +542,7 @@ class API: def get_settings(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-account-settings """ return bind_api( - self, 'GET', *args, - path='/account/settings.json', + self, 'GET', '/account/settings.json', *args, use_cache=False, **kwargs ) @@ -588,8 +555,7 @@ class API: 'allow_contributor_request', 'lang' """ return bind_api( - self, 'POST', *args, - path='/account/settings.json', + self, 'POST', '/account/settings.json', *args, allowed_param=['sleep_time_enabled', 'start_sleep_time', 'end_sleep_time', 'time_zone', 'trend_location_woeid', @@ -606,8 +572,7 @@ class API: kwargs['include_email'] = str(kwargs['include_email']).lower() try: return bind_api( - self, 'GET', - path='/account/verify_credentials.json', + self, 'GET', '/account/verify_credentials.json', require_auth=True, allowed_param=['include_entities', 'skip_status', 'include_email'], **kwargs @@ -623,8 +588,7 @@ class API: :allowed_param: 'resources' """ return bind_api( - self, 'GET', *args, - path='/application/rate_limit_status.json', + self, 'GET', '/application/rate_limit_status.json', *args, allowed_param=['resources'], use_cache=False, **kwargs ) @@ -636,8 +600,7 @@ class API: """ headers, post_data = API._pack_image(filename, 700, f=file_) return bind_api( - self, 'POST', *args, - path='/account/update_profile_image.json', + self, 'POST', '/account/update_profile_image.json', *args, allowed_param=['include_entities', 'skip_status'], require_auth=True, post_data=post_data, headers=headers, **kwargs @@ -651,8 +614,7 @@ class API: headers, post_data = API._pack_image(filename, 700, form_field='banner', f=f) return bind_api( - self, 'POST', - path='/account/update_profile_banner.json', + self, 'POST', '/account/update_profile_banner.json', allowed_param=['width', 'height', 'offset_left', 'offset_right'], require_auth=True, post_data=post_data, headers=headers @@ -665,8 +627,7 @@ class API: 'profile_link_color' """ return bind_api( - self, 'POST', *args, - path='/account/update_profile.json', + self, 'POST', '/account/update_profile.json', *args, allowed_param=['name', 'url', 'location', 'description', 'profile_link_color'], require_auth=True, **kwargs @@ -680,8 +641,7 @@ class API: 'since_id' """ return bind_api( - self, 'GET', *args, - path='/favorites/list.json', + self, 'GET', '/favorites/list.json', *args, allowed_param=['screen_name', 'user_id', 'max_id', 'count', 'since_id'], **kwargs ) @@ -692,8 +652,7 @@ class API: :allowed_param: 'id' """ return bind_api( - self, 'POST', *args, - path='/favorites/create.json', + self, 'POST', '/favorites/create.json', *args, allowed_param=['id'], require_auth=True, **kwargs ) @@ -704,8 +663,7 @@ class API: :allowed_param: 'id' """ return bind_api( - self, 'POST', *args, - path='/favorites/destroy.json', + self, 'POST', '/favorites/destroy.json', *args, allowed_param=['id'], require_auth=True, **kwargs ) @@ -716,8 +674,7 @@ class API: :allowed_param: 'id', 'user_id', 'screen_name' """ return bind_api( - self, 'POST', *args, - path='/blocks/create.json', + self, 'POST', '/blocks/create.json', *args, allowed_param=['id', 'user_id', 'screen_name'], require_auth=True, **kwargs ) @@ -728,8 +685,7 @@ class API: :allowed_param: 'id', 'user_id', 'screen_name' """ return bind_api( - self, 'POST', *args, - path='/blocks/destroy.json', + self, 'POST', '/blocks/destroy.json', *args, allowed_param=['id', 'user_id', 'screen_name'], require_auth=True, **kwargs ) @@ -741,8 +697,7 @@ class API: :allowed_param: 'cursor' """ return bind_api( - self, 'GET', *args, - path='/mutes/users/ids.json', + self, 'GET', '/mutes/users/ids.json', *args, allowed_param=['cursor'], require_auth=True, **kwargs ) @@ -754,8 +709,7 @@ class API: :allowed_param: 'cursor', 'include_entities', 'skip_status' """ return bind_api( - self, 'GET', *args, - path='/mutes/users/list.json', + self, 'GET', '/mutes/users/list.json', *args, allowed_param=['cursor', 'include_entities', 'skip_status'], required_auth=True, **kwargs ) @@ -766,8 +720,7 @@ class API: :allowed_param: 'id', 'user_id', 'screen_name' """ return bind_api( - self, 'POST', *args, - path='/mutes/users/create.json', + self, 'POST', '/mutes/users/create.json', *args, allowed_param=['id', 'user_id', 'screen_name'], require_auth=True, **kwargs ) @@ -778,8 +731,7 @@ class API: :allowed_param: 'id', 'user_id', 'screen_name' """ return bind_api( - self, 'POST', *args, - path='/mutes/users/destroy.json', + self, 'POST', '/mutes/users/destroy.json', *args, allowed_param=['id', 'user_id', 'screen_name'], require_auth=True, **kwargs ) @@ -791,8 +743,7 @@ class API: :allowed_param: 'cursor' """ return bind_api( - self, 'GET', *args, - path='/blocks/list.json', + self, 'GET', '/blocks/list.json', *args, allowed_param=['cursor'], require_auth=True, **kwargs ) @@ -804,8 +755,7 @@ class API: :allowed_param: 'cursor' """ return bind_api( - self, 'GET', *args, - path='/blocks/ids.json', + self, 'GET', '/blocks/ids.json', *args, allowed_param=['cursor'], require_auth=True, **kwargs ) @@ -816,8 +766,7 @@ class API: :allowed_param: 'user_id', 'screen_name', 'perform_block' """ return bind_api( - self, 'POST', *args, - path='/users/report_spam.json', + self, 'POST', '/users/report_spam.json', *args, allowed_param=['user_id', 'screen_name', 'perform_block'], require_auth=True, **kwargs ) @@ -826,8 +775,7 @@ class API: def saved_searches(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-saved_searches-list """ return bind_api( - self, 'GET', *args, - path='/saved_searches/list.json', + self, 'GET', '/saved_searches/list.json', *args, require_auth=True, **kwargs ) @@ -837,8 +785,7 @@ class API: :allowed_param: """ return bind_api( - self, 'GET', *args, - path=f'/saved_searches/show/{saved_search_id}.json', + self, 'GET', f'/saved_searches/show/{saved_search_id}.json', *args, require_auth=True, **kwargs ) @@ -848,8 +795,7 @@ class API: :allowed_param: 'query' """ return bind_api( - self, 'POST', *args, - path='/saved_searches/create.json', + self, 'POST', '/saved_searches/create.json', *args, allowed_param=['query'], require_auth=True, **kwargs ) @@ -860,8 +806,8 @@ class API: :allowed_param: """ return bind_api( - self, 'POST', *args, - path=f'/saved_searches/destroy/{saved_search_id}.json', + self, 'POST', f'/saved_searches/destroy/{saved_search_id}.json', + *args, require_auth=True, **kwargs ) @@ -871,8 +817,7 @@ class API: :allowed_param: 'name', 'mode', 'description' """ return bind_api( - self, 'POST', *args, - path='/lists/create.json', + self, 'POST', '/lists/create.json', *args, allowed_param=['name', 'mode', 'description'], require_auth=True, **kwargs ) @@ -883,8 +828,7 @@ class API: :allowed_param: 'owner_screen_name', 'owner_id', 'list_id', 'slug' """ return bind_api( - self, 'POST', *args, - path='/lists/destroy.json', + self, 'POST', '/lists/destroy.json', *args, allowed_param=['owner_screen_name', 'owner_id', 'list_id', 'slug'], require_auth=True, **kwargs ) @@ -896,8 +840,7 @@ class API: 'owner_screen_name', 'owner_id' """ return bind_api( - self, 'POST', *args, - path='/lists/update.json', + self, 'POST', '/lists/update.json', *args, allowed_param=['list_id', 'slug', 'name', 'mode', 'description', 'owner_screen_name', 'owner_id'], require_auth=True, **kwargs @@ -909,8 +852,7 @@ class API: :allowed_param: 'screen_name', 'user_id', 'reverse' """ return bind_api( - self, 'GET', *args, - path='/lists/list.json', + self, 'GET', '/lists/list.json', *args, allowed_param=['screen_name', 'user_id', 'reverse'], require_auth=True, **kwargs ) @@ -923,8 +865,7 @@ class API: 'cursor', 'count' """ return bind_api( - self, 'GET', *args, - path='/lists/memberships.json', + self, 'GET', '/lists/memberships.json', *args, allowed_param=['screen_name', 'user_id', 'filter_to_owned_lists', 'cursor', 'count'], require_auth=True, **kwargs @@ -937,8 +878,7 @@ class API: :allowed_param: 'user_id', 'screen_name', 'count', 'cursor' """ return bind_api( - self, 'GET', *args, - path='/lists/ownerships.json', + self, 'GET', '/lists/ownerships.json', *args, allowed_param=['user_id', 'screen_name', 'count', 'cursor'], require_auth=True, **kwargs ) @@ -950,8 +890,7 @@ class API: :allowed_param: 'screen_name', 'user_id', 'cursor', 'count' """ return bind_api( - self, 'GET', *args, - path='/lists/subscriptions.json', + self, 'GET', '/lists/subscriptions.json', *args, allowed_param=['screen_name', 'user_id', 'cursor', 'count'], require_auth=True, **kwargs ) @@ -965,8 +904,7 @@ class API: 'include_rts' """ return bind_api( - self, 'GET', *args, - path='/lists/statuses.json', + self, 'GET', '/lists/statuses.json', *args, allowed_param=['owner_screen_name', 'slug', 'owner_id', 'list_id', 'since_id', 'max_id', 'count', 'include_entities', 'include_rts'], **kwargs @@ -978,8 +916,7 @@ class API: :allowed_param: 'owner_screen_name', 'owner_id', 'slug', 'list_id' """ return bind_api( - self, 'GET', *args, - path='/lists/show.json', + self, 'GET', '/lists/show.json', *args, allowed_param=['owner_screen_name', 'owner_id', 'slug', 'list_id'], **kwargs ) @@ -991,8 +928,7 @@ class API: 'owner_id', 'slug', 'list_id' """ return bind_api( - self, 'POST', *args, - path='/lists/members/create.json', + self, 'POST', '/lists/members/create.json', *args, allowed_param=['screen_name', 'user_id', 'owner_screen_name', 'owner_id', 'slug', 'list_id'], require_auth=True, **kwargs @@ -1005,8 +941,7 @@ class API: 'owner_id', 'slug', 'list_id' """ return bind_api( - self, 'POST', *args, - path='/lists/members/destroy.json', + self, 'POST', '/lists/members/destroy.json', *args, allowed_param=['screen_name', 'user_id', 'owner_screen_name', 'owner_id', 'slug', 'list_id'], require_auth=True, **kwargs @@ -1021,9 +956,9 @@ class API: 'owner_id', 'owner_screen_name' """ return bind_api( - self, 'POST', list_to_csv(screen_name), list_to_csv(user_id), slug, - list_id, owner_id, owner_screen_name, - path='/lists/members/create_all.json', + self, 'POST', '/lists/members/create_all.json', + list_to_csv(screen_name), list_to_csv(user_id), slug, list_id, + owner_id, owner_screen_name, allowed_param=['screen_name', 'user_id', 'slug', 'list_id', 'owner_id', 'owner_screen_name'], require_auth=True, **kwargs @@ -1038,9 +973,9 @@ class API: 'owner_id', 'owner_screen_name' """ return bind_api( - self, 'POST', list_to_csv(screen_name), list_to_csv(user_id), slug, - list_id, owner_id, owner_screen_name, - path='/lists/members/destroy_all.json', + self, 'POST', '/lists/members/destroy_all.json', + list_to_csv(screen_name), list_to_csv(user_id), slug, list_id, + owner_id, owner_screen_name, allowed_param=['screen_name', 'user_id', 'slug', 'list_id', 'owner_id', 'owner_screen_name'], require_auth=True, **kwargs @@ -1054,8 +989,7 @@ class API: 'cursor' """ return bind_api( - self, 'GET', *args, - path='/lists/members.json', + self, 'GET', '/lists/members.json', *args, allowed_param=['owner_screen_name', 'slug', 'list_id', 'owner_id', 'cursor'], **kwargs ) @@ -1067,8 +1001,7 @@ class API: 'owner_screen_name', 'owner_id' """ return bind_api( - self, 'GET', *args, - path='/lists/members/show.json', + self, 'GET', '/lists/members/show.json', *args, allowed_param=['list_id', 'slug', 'user_id', 'screen_name', 'owner_screen_name', 'owner_id'], **kwargs ) @@ -1079,8 +1012,7 @@ class API: :allowed_param: 'owner_screen_name', 'slug', 'owner_id', 'list_id' """ return bind_api( - self, 'POST', *args, - path='/lists/subscribers/create.json', + self, 'POST', '/lists/subscribers/create.json', *args, allowed_param=['owner_screen_name', 'slug', 'owner_id', 'list_id'], require_auth=True, **kwargs ) @@ -1091,8 +1023,7 @@ class API: :allowed_param: 'owner_screen_name', 'slug', 'owner_id', 'list_id' """ return bind_api( - self, 'POST', *args, - path='/lists/subscribers/destroy.json', + self, 'POST', '/lists/subscribers/destroy.json', *args, allowed_param=['owner_screen_name', 'slug', 'owner_id', 'list_id'], require_auth=True, **kwargs ) @@ -1106,8 +1037,7 @@ class API: 'skip_status' """ return bind_api( - self, 'GET', *args, - path='/lists/subscribers.json', + self, 'GET', '/lists/subscribers.json', *args, allowed_param=['owner_screen_name', 'slug', 'owner_id', 'list_id', 'cursor', 'count', 'include_entities', 'skip_status'], **kwargs @@ -1120,8 +1050,7 @@ class API: 'owner_id', 'list_id', 'user_id' """ return bind_api( - self, 'GET', *args, - path='/lists/subscribers/show.json', + self, 'GET', '/lists/subscribers/show.json', *args, allowed_param=['owner_screen_name', 'slug', 'screen_name', 'owner_id', 'list_id', 'user_id'], **kwargs ) @@ -1129,11 +1058,7 @@ class API: @payload('json') def trends_available(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/trends/locations-with-trending-topics/api-reference/get-trends-available """ - return bind_api( - self, 'GET', *args, - path='/trends/available.json', - **kwargs - ) + return bind_api(self, 'GET', '/trends/available.json', *args, **kwargs) @payload('json') def trends_place(self, *args, **kwargs): @@ -1141,8 +1066,7 @@ class API: :allowed_param: 'id', 'exclude' """ return bind_api( - self, 'GET', *args, - path='/trends/place.json', + self, 'GET', '/trends/place.json', *args, allowed_param=['id', 'exclude'], **kwargs ) @@ -1152,8 +1076,7 @@ class API: :allowed_param: 'lat', 'long' """ return bind_api( - self, 'GET', *args, - path='/trends/closest.json', + self, 'GET', '/trends/closest.json', *args, allowed_param=['lat', 'long'], **kwargs ) @@ -1166,8 +1089,7 @@ class API: 'include_entities' """ return bind_api( - self, 'GET', *args, - path='/search/tweets.json', + self, 'GET', '/search/tweets.json', *args, allowed_param=['q', 'lang', 'locale', 'since_id', 'geocode', 'max_id', 'until', 'result_type', 'count', 'include_entities'], **kwargs @@ -1181,8 +1103,8 @@ class API: 'next' """ return bind_api( - self, 'GET', *args, - path=f'/tweets/search/30day/{environment_name}.json', + self, 'GET', f'/tweets/search/30day/{environment_name}.json', + *args, allowed_param=['query', 'tag', 'fromDate', 'toDate', 'maxResults', 'next'], require_auth=True, **kwargs @@ -1196,8 +1118,8 @@ class API: 'next' """ return bind_api( - self, 'GET', *args, - path=f'/tweets/search/fullarchive/{environment_name}.json', + self, 'GET', f'/tweets/search/fullarchive/{environment_name}.json', + *args, allowed_param=['query', 'tag', 'fromDate', 'toDate', 'maxResults', 'next'], require_auth=True, **kwargs @@ -1210,8 +1132,7 @@ class API: 'max_results' """ return bind_api( - self, 'GET', *args, - path='/geo/reverse_geocode.json', + self, 'GET', '/geo/reverse_geocode.json', *args, allowed_param=['lat', 'long', 'accuracy', 'granularity', 'max_results'], **kwargs ) @@ -1222,9 +1143,7 @@ class API: :allowed_param: """ return bind_api( - self, 'GET', *args, - path=f'/geo/id/{place_id}.json', - **kwargs + self, 'GET', f'/geo/id/{place_id}.json', *args, **kwargs ) @payload('place', list=True) @@ -1235,8 +1154,7 @@ class API: """ return bind_api( - self, 'GET', *args, - path='/geo/search.json', + self, 'GET', '/geo/search.json', *args, allowed_param=['lat', 'long', 'query', 'ip', 'granularity', 'accuracy', 'max_results', 'contained_within'], **kwargs @@ -1246,8 +1164,7 @@ class API: def supported_languages(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/developer-utilities/supported-languages/api-reference/get-help-languages """ return bind_api( - self, 'GET', *args, - path='/help/languages.json', + self, 'GET', '/help/languages.json', *args, require_auth=True, **kwargs ) @@ -1255,8 +1172,7 @@ class API: def configuration(self, *args, **kwargs): """ :reference: https://developer.twitter.com/en/docs/developer-utilities/configuration/api-reference/get-help-configuration """ return bind_api( - self, 'GET', *args, - path='/help/configuration.json', + self, 'GET', '/help/configuration.json', *args, require_auth=True, **kwargs ) diff --git a/tweepy/binder.py b/tweepy/binder.py index feafe1e..f8ff517 100644 --- a/tweepy/binder.py +++ b/tweepy/binder.py @@ -167,8 +167,7 @@ def execute(api, method, path, *args, allowed_param=[], params=None, session.close() -def bind_api(api, method, *args, **kwargs): - path = kwargs.pop('path') +def bind_api(api, method, path, *args, **kwargs): return execute(api, method, path, *args, **kwargs) -- 2.25.1