From 74465360e0698cda2616b0d6cd57413be3c9ce77 Mon Sep 17 00:00:00 2001 From: Harmon Date: Fri, 29 Jan 2021 10:59:25 -0600 Subject: [PATCH] Replace APIMethod.headers with APIMethod.execute keyword-only argument Replace APIMethod.headers with APIMethod.execute headers keyword-only argument --- tweepy/binder.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tweepy/binder.py b/tweepy/binder.py index 2fa300a..2f64c68 100644 --- a/tweepy/binder.py +++ b/tweepy/binder.py @@ -25,7 +25,6 @@ class APIMethod: self.session = requests.Session() self.parser = kwargs.pop('parser', api.parser) - self.headers = kwargs.pop('headers', {}) self.build_parameters(args, kwargs) # Monitoring rate limits @@ -52,9 +51,9 @@ class APIMethod: log.debug("PARAMS: %r", self.session.params) - def execute(self, method, path, *, json_payload=None, post_data=None, - require_auth=False, return_cursors=False, upload_api=False, - use_cache=True): + def execute(self, method, path, *, headers=None, json_payload=None, + post_data=None, require_auth=False, return_cursors=False, + upload_api=False, use_cache=True): # If authentication is required and no credentials # are provided, throw an error. if require_auth and not self.api.auth: @@ -117,7 +116,7 @@ class APIMethod: try: resp = self.session.request(method, full_url, - headers=self.headers, + headers=headers, data=post_data, json=json_payload, timeout=self.api.timeout, @@ -183,6 +182,7 @@ class APIMethod: def bind_api(*args, **kwargs): http_method = kwargs.pop('method', 'GET') path = kwargs.pop('path') + headers = kwargs.pop('headers', {}) json_payload = kwargs.pop('json_payload', None) post_data = kwargs.pop('post_data', None) require_auth = kwargs.pop('require_auth', False) @@ -196,7 +196,7 @@ def bind_api(*args, **kwargs): return method else: return method.execute( - http_method, path, json_payload=json_payload, + http_method, path, headers=headers, json_payload=json_payload, post_data=post_data, require_auth=require_auth, return_cursors=return_cursors, upload_api=upload_api, use_cache=use_cache -- 2.25.1