From 807f9371b6f0a796fea6093497401a1d10b5e183 Mon Sep 17 00:00:00 2001 From: Harmon Date: Wed, 7 Apr 2021 13:44:20 -0500 Subject: [PATCH] Remove API.me, AuthHandler.get_username, and OAuthHandler.get_username --- docs/api.rst | 10 ---------- tests/test_api.py | 11 +++-------- tweepy/api.py | 4 ---- tweepy/auth.py | 15 --------------- 4 files changed, 3 insertions(+), 37 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index b8a601b..90025ea 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -136,16 +136,6 @@ Follow, search, and get users .. automethod:: API.get_user -User methods ------------- - -.. method:: API.me() - - Returns the authenticated user's information. - - :rtype: :class:`User` object - - Direct Message Methods ---------------------- diff --git a/tests/test_api.py b/tests/test_api.py index 6607769..f123363 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -130,18 +130,13 @@ class TweepyAPITests(TweepyTestCase): def testsearchusers(self): self.api.search_users('twitter') - @tape.use_cassette('testme.json') - def testme(self): - me = self.api.me() - self.assertEqual(me.screen_name, username) - @tape.use_cassette('testlistdirectmessages.json') def testlistdirectmessages(self): self.api.list_direct_messages() @tape.use_cassette('testsendanddestroydirectmessage.json') def testsendanddestroydirectmessage(self): - me = self.api.me() + me = self.api.verify_credentials() # send sent_dm = self.api.send_direct_message(me.id, text='test message') @@ -200,7 +195,7 @@ class TweepyAPITests(TweepyTestCase): @tape.use_cassette('testupdateprofilecolors.json') def testupdateprofilecolors(self): - original = self.api.me() + original = self.api.verify_credentials() updated = self.api.update_profile(profile_link_color='D0F900') # restore colors @@ -225,7 +220,7 @@ class TweepyAPITests(TweepyTestCase): @tape.use_cassette('testupdateprofile.json') def testupdateprofile(self): - original = self.api.me() + original = self.api.verify_credentials() profile = { 'name': 'Tweepy test 123', 'location': 'pytopia', diff --git a/tweepy/api.py b/tweepy/api.py index 47592e6..9a7e36e 100644 --- a/tweepy/api.py +++ b/tweepy/api.py @@ -1843,10 +1843,6 @@ class API: ), command='STATUS', media_id=media_id, upload_api=True, **kwargs ) - def me(self): - """ Get the authenticated user """ - return self.get_user(screen_name=self.auth.get_username()) - @payload('direct_message') def get_direct_message(self, id, **kwargs): """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/direct-messages/sending-and-receiving/api-reference/get-event diff --git a/tweepy/auth.py b/tweepy/auth.py index dc6c968..7d481f6 100644 --- a/tweepy/auth.py +++ b/tweepy/auth.py @@ -25,10 +25,6 @@ class AuthHandler: """Apply authentication headers to request""" raise NotImplementedError - def get_username(self): - """Return the username of the authenticated user""" - raise NotImplementedError - class OAuthHandler(AuthHandler): """OAuth authentication handler""" @@ -134,17 +130,6 @@ class OAuthHandler(AuthHandler): except Exception as e: raise TweepyException(e) - def get_username(self): - if self.username is None: - api = API(self) - user = api.verify_credentials() - if user: - self.username = user.screen_name - else: - raise TweepyException('Unable to get username,' - ' invalid oauth token!') - return self.username - class OAuth2Bearer(AuthBase): def __init__(self, bearer_token): -- 2.25.1