From dda2ec6ccd9b5df44daf7b8574d183ac0c2503fa Mon Sep 17 00:00:00 2001 From: Harmon Date: Tue, 2 Feb 2021 11:46:06 -0600 Subject: [PATCH] Remove method parameter from parse method for Parser and its subclasses --- tweepy/binder.py | 3 +-- tweepy/cursor.py | 10 +++++----- tweepy/parsers.py | 10 +++++----- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/tweepy/binder.py b/tweepy/binder.py index 8a3cebb..2856058 100644 --- a/tweepy/binder.py +++ b/tweepy/binder.py @@ -164,8 +164,7 @@ class APIMethod: # Parse the response payload return_cursors = (return_cursors or 'cursor' in self.session.params or 'next' in self.session.params) - result = parser.parse(self, resp.text, api=api, - payload_list=payload_list, + result = parser.parse(resp.text, api=api, payload_list=payload_list, payload_type=payload_type, return_cursors=return_cursors) diff --git a/tweepy/cursor.py b/tweepy/cursor.py index fbc8ae8..01e6136 100644 --- a/tweepy/cursor.py +++ b/tweepy/cursor.py @@ -133,12 +133,12 @@ class IdIterator(BaseIterator): # This is a special invocation that returns the underlying # APIMethod class - model = ModelParser().parse(self.method(create=True), data, - payload_list=self.method.payload_list, - payload_type=self.method.payload_type) + model = ModelParser().parse( + data, payload_list=self.method.payload_list, + payload_type=self.method.payload_type + ) result = self.method.__self__.parser.parse( - self.method(create=True), data, - payload_list=self.method.payload_list, + data, payload_list=self.method.payload_list, payload_type=self.method.payload_type ) diff --git a/tweepy/parsers.py b/tweepy/parsers.py index fe78923..cda1bf0 100644 --- a/tweepy/parsers.py +++ b/tweepy/parsers.py @@ -10,7 +10,7 @@ from tweepy.models import ModelFactory class Parser: - def parse(self, method, payload, *args, **kwargs): + def parse(self, payload, *args, **kwargs): """ Parse the response payload and return the result. Returns a tuple that contains the result data and the cursors @@ -32,7 +32,7 @@ class RawParser(Parser): def __init__(self): pass - def parse(self, method, payload, *args, **kwargs): + def parse(self, payload, *args, **kwargs): return payload def parse_error(self, payload): @@ -43,7 +43,7 @@ class JSONParser(Parser): payload_format = 'json' - def parse(self, method, payload, *, return_cursors=False, **kwargs): + def parse(self, payload, *, return_cursors=False, **kwargs): try: json = json_lib.loads(payload) except Exception as e: @@ -81,7 +81,7 @@ class ModelParser(JSONParser): JSONParser.__init__(self) self.model_factory = model_factory or ModelFactory - def parse(self, method, payload, *, api=None, payload_list=False, + def parse(self, payload, *, api=None, payload_list=False, payload_type=None, return_cursors=False): try: if payload_type is None: @@ -90,7 +90,7 @@ class ModelParser(JSONParser): except AttributeError: raise TweepError(f'No model for this payload type: {payload_type}') - json = JSONParser.parse(self, method, payload, return_cursors=return_cursors) + json = JSONParser.parse(self, payload, return_cursors=return_cursors) if isinstance(json, tuple): json, cursors = json else: -- 2.25.1