From: Harmon Date: Sun, 25 Aug 2019 08:20:13 +0000 (-0500) Subject: Replace references to kargs with kwargs X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f496872ffdb4bdab2c4c259ce13839b4fe653580;p=tweepy.git Replace references to kargs with kwargs --- diff --git a/tests/test_cursors.py b/tests/test_cursors.py index ebd8cbe..3f46157 100644 --- a/tests/test_cursors.py +++ b/tests/test_cursors.py @@ -33,7 +33,7 @@ class TweepyCursorTests(TweepyTestCase): def testcursorsetstartcursor(self): c = Cursor(self.api.friends_ids, cursor=123456) self.assertEqual(c.iterator.next_cursor, 123456) - self.assertFalse('cursor' in c.iterator.kargs) + self.assertFalse('cursor' in c.iterator.kwargs) @tape.use_cassette('testcursornext.json') def testcursornext(self): diff --git a/tweepy/api.py b/tweepy/api.py index 9cd14a1..fa9f422 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -591,7 +591,7 @@ class API(object): use_cache=False ) - def verify_credentials(self, **kargs): + def verify_credentials(self, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials :allowed_param:'include_entities', 'skip_status', 'include_email' """ @@ -602,7 +602,7 @@ class API(object): payload_type='user', require_auth=True, allowed_param=['include_entities', 'skip_status', 'include_email'], - )(**kargs) + )(**kwargs) except TweepError as e: if e.response and e.response.status == 401: return False @@ -635,11 +635,11 @@ class API(object): require_auth=True )(self, post_data=post_data, headers=headers) - def update_profile_background_image(self, filename, **kargs): + def update_profile_background_image(self, filename, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_background_image :allowed_param:'tile', 'include_entities', 'skip_status', 'use' """ - f = kargs.pop('file', None) + f = kwargs.pop('file', None) headers, post_data = API._pack_image(filename, 800, f=f) return bind_api( api=self, @@ -650,11 +650,11 @@ class API(object): require_auth=True )(post_data=post_data, headers=headers) - def update_profile_banner(self, filename, **kargs): + def update_profile_banner(self, filename, **kwargs): """ :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_banner :allowed_param:'width', 'height', 'offset_left', 'offset_right' """ - f = kargs.pop('file', None) + f = kwargs.pop('file', None) headers, post_data = API._pack_image(filename, 700, form_field="banner", f=f) return bind_api( api=self, diff --git a/tweepy/cursor.py b/tweepy/cursor.py index 746b1e8..2f0cf2d 100644 --- a/tweepy/cursor.py +++ b/tweepy/cursor.py @@ -9,14 +9,14 @@ from tweepy.parsers import ModelParser, RawParser class Cursor(object): """Pagination helper class""" - def __init__(self, method, *args, **kargs): + def __init__(self, method, *args, **kwargs): if hasattr(method, 'pagination_mode'): if method.pagination_mode == 'cursor': - self.iterator = CursorIterator(method, args, kargs) + self.iterator = CursorIterator(method, args, kwargs) elif method.pagination_mode == 'id': - self.iterator = IdIterator(method, args, kargs) + self.iterator = IdIterator(method, args, kwargs) elif method.pagination_mode == 'page': - self.iterator = PageIterator(method, args, kargs) + self.iterator = PageIterator(method, args, kwargs) else: raise TweepError('Invalid pagination mode.') else: @@ -37,10 +37,10 @@ class Cursor(object): class BaseIterator(object): - def __init__(self, method, args, kargs): + def __init__(self, method, args, kwargs): self.method = method self.args = args - self.kargs = kargs + self.kwargs = kwargs self.limit = 0 def __next__(self): @@ -58,9 +58,9 @@ class BaseIterator(object): class CursorIterator(BaseIterator): - def __init__(self, method, args, kargs): - BaseIterator.__init__(self, method, args, kargs) - start_cursor = kargs.pop('cursor', None) + def __init__(self, method, args, kwargs): + BaseIterator.__init__(self, method, args, kwargs) + start_cursor = kwargs.pop('cursor', None) self.next_cursor = start_cursor or -1 self.prev_cursor = start_cursor or 0 self.num_tweets = 0 @@ -70,7 +70,7 @@ class CursorIterator(BaseIterator): raise StopIteration data, cursors = self.method(cursor=self.next_cursor, *self.args, - **self.kargs) + **self.kwargs) self.prev_cursor, self.next_cursor = cursors if len(data) == 0: raise StopIteration @@ -82,16 +82,16 @@ class CursorIterator(BaseIterator): raise TweepError('Can not page back more, at first page') data, self.next_cursor, self.prev_cursor = self.method(cursor=self.prev_cursor, *self.args, - **self.kargs) + **self.kwargs) self.num_tweets -= 1 return data class IdIterator(BaseIterator): - def __init__(self, method, args, kargs): - BaseIterator.__init__(self, method, args, kargs) - self.max_id = kargs.pop('max_id', None) + def __init__(self, method, args, kwargs): + BaseIterator.__init__(self, method, args, kwargs) + self.max_id = kwargs.pop('max_id', None) self.num_tweets = 0 self.results = [] self.model_results = [] @@ -103,7 +103,7 @@ class IdIterator(BaseIterator): raise StopIteration if self.index >= len(self.results) - 1: - data = self.method(max_id=self.max_id, parser=RawParser(), *self.args, **self.kargs) + data = self.method(max_id=self.max_id, parser=RawParser(), *self.args, **self.kwargs) if hasattr(self.method, '__self__'): old_parser = self.method.__self__.parser @@ -155,8 +155,8 @@ class IdIterator(BaseIterator): class PageIterator(BaseIterator): - def __init__(self, method, args, kargs): - BaseIterator.__init__(self, method, args, kargs) + def __init__(self, method, args, kwargs): + BaseIterator.__init__(self, method, args, kwargs) self.current_page = 0 def next(self): @@ -164,7 +164,7 @@ class PageIterator(BaseIterator): if self.current_page > self.limit: raise StopIteration - items = self.method(page=self.current_page, *self.args, **self.kargs) + items = self.method(page=self.current_page, *self.args, **self.kwargs) if len(items) == 0: raise StopIteration self.current_page += 1 @@ -174,7 +174,7 @@ class PageIterator(BaseIterator): if self.current_page == 1: raise TweepError('Can not page back more, at first page') self.current_page -= 1 - return self.method(page=self.current_page, *self.args, **self.kargs) + return self.method(page=self.current_page, *self.args, **self.kwargs) class ItemIterator(BaseIterator): diff --git a/tweepy/models.py b/tweepy/models.py index 09ac79d..7c33d8f 100644 --- a/tweepy/models.py +++ b/tweepy/models.py @@ -174,14 +174,14 @@ class User(Model): results.append(cls.parse(api, obj)) return results - def timeline(self, **kargs): - return self._api.user_timeline(user_id=self.id, **kargs) + def timeline(self, **kwargs): + return self._api.user_timeline(user_id=self.id, **kwargs) - def friends(self, **kargs): - return self._api.friends(user_id=self.id, **kargs) + def friends(self, **kwargs): + return self._api.friends(user_id=self.id, **kwargs) - def followers(self, **kargs): - return self._api.followers(user_id=self.id, **kargs) + def followers(self, **kwargs): + return self._api.followers(user_id=self.id, **kwargs) def follow(self): self._api.create_friendship(user_id=self.id) @@ -191,25 +191,25 @@ class User(Model): self._api.destroy_friendship(user_id=self.id) self.following = False - def lists_memberships(self, *args, **kargs): + def lists_memberships(self, *args, **kwargs): return self._api.lists_memberships(user=self.screen_name, *args, - **kargs) + **kwargs) - def lists_subscriptions(self, *args, **kargs): + def lists_subscriptions(self, *args, **kwargs): return self._api.lists_subscriptions(user=self.screen_name, *args, - **kargs) + **kwargs) - def lists(self, *args, **kargs): + def lists(self, *args, **kwargs): return self._api.lists_all(user=self.screen_name, *args, - **kargs) + **kwargs) - def followers_ids(self, *args, **kargs): + def followers_ids(self, *args, **kwargs): return self._api.followers_ids(user_id=self.id, *args, - **kargs) + **kwargs) def __eq__(self, other): if isinstance(other, User): @@ -333,16 +333,16 @@ class List(Model): results.append(cls.parse(api, obj)) return results - def update(self, **kargs): - return self._api.update_list(self.slug, **kargs) + def update(self, **kwargs): + return self._api.update_list(self.slug, **kwargs) def destroy(self): return self._api.destroy_list(self.slug) - def timeline(self, **kargs): + def timeline(self, **kwargs): return self._api.list_timeline(self.user.screen_name, self.slug, - **kargs) + **kwargs) def add_member(self, id): return self._api.add_list_member(self.slug, id) @@ -350,10 +350,10 @@ class List(Model): def remove_member(self, id): return self._api.remove_list_member(self.slug, id) - def members(self, **kargs): + def members(self, **kwargs): return self._api.list_members(self.user.screen_name, self.slug, - **kargs) + **kwargs) def is_member(self, id): return self._api.is_list_member(self.user.screen_name, @@ -366,10 +366,10 @@ class List(Model): def unsubscribe(self): return self._api.unsubscribe_list(self.user.screen_name, self.slug) - def subscribers(self, **kargs): + def subscribers(self, **kwargs): return self._api.list_subscribers(self.user.screen_name, self.slug, - **kargs) + **kwargs) def is_subscribed(self, id): return self._api.is_subscribed_list(self.user.screen_name,