Rename Client.follow and Client.unfollow
authorHarmon <Harmon758@gmail.com>
Mon, 25 Oct 2021 08:36:59 +0000 (03:36 -0500)
committerHarmon <Harmon758@gmail.com>
Mon, 25 Oct 2021 08:36:59 +0000 (03:36 -0500)
Rename Client.follow and Client.unfollow to Client.follow_user and Client.unfollow_user, respectively
Client.follow and Client.unfollow are kept as deprecated aliases

cassettes/test_follow_and_unfollow_user.yaml [moved from cassettes/test_follow_and_unfollow.yaml with 100% similarity]
docs/client.rst
tests/test_client.py
tweepy/client.py

index 4c3f6f7c5ecd75585dc2d1c7dae7a4f7d83598b0..3d7b56263d79e05313aa147d981b5da692b11485 100644 (file)
@@ -81,12 +81,16 @@ Blocks
 Follows
 -------
 
+.. automethod:: Client.unfollow_user
+
 .. automethod:: Client.unfollow
 
 .. automethod:: Client.get_users_followers
 
 .. automethod:: Client.get_users_following
 
+.. automethod:: Client.follow_user
+
 .. automethod:: Client.follow
 
 Mutes
index e708086655873cba139bb1857093026cce413223..66bef3c87e0856f95470b9e7f24359cbaf3dec20 100644 (file)
@@ -92,11 +92,11 @@ class TweepyTestCase(unittest.TestCase):
         self.client.get_blocked()
         self.client.unblock(user_id)
 
-    @tape.use_cassette("test_follow_and_unfollow.yaml", serializer="yaml")
-    def test_follow_and_unfollow(self):
+    @tape.use_cassette("test_follow_and_unfollow_user.yaml", serializer="yaml")
+    def test_follow_and_unfollow_user(self):
         user_id = 17874544  # User ID for @TwitterSupport
-        self.client.follow(user_id)
-        self.client.unfollow(user_id)
+        self.client.follow_user(user_id)
+        self.client.unfollow_user(user_id)
 
     @tape.use_cassette("test_get_users_followers.yaml", serializer="yaml")
     def test_get_users_followers(self):
index 55aaf04bffe021fe4715ead543020ea954a912db..367861239bcc293151f0434a0368a153a87f542f 100644 (file)
@@ -7,6 +7,7 @@ import datetime
 import logging
 from platform import python_version
 import time
+import warnings
 
 import requests
 
@@ -1192,7 +1193,7 @@ class Client:
 
     # Follows
 
-    def unfollow(self, target_user_id):
+    def unfollow_user(self, target_user_id):
         """Allows a user ID to unfollow another user.
 
         The request succeeds with no action when the authenticated user sends a
@@ -1218,6 +1219,18 @@ class Client:
             "DELETE", route, user_auth=True
         )
 
+    def unfollow(self, target_user_id):
+        """Alias for :meth:`Client.unfollow_user`
+
+        .. deprecated:: 4.2
+            Use :meth:`Client.unfollow_user` instead.
+        """
+        warnings.warn(
+            "Client.unfollow is deprecated; use Client.unfollow_user instead.",
+            DeprecationWarning
+        )
+        self.unfollow_user(target_user_id)
+
     def get_users_followers(self, id, *, user_auth=False, **params):
         """get_users_followers( \
             id, *, user_auth=False, expansions, max_results, \
@@ -1313,7 +1326,7 @@ class Client:
             ), data_type=User, user_auth=user_auth
         )
 
-    def follow(self, target_user_id):
+    def follow_user(self, target_user_id):
         """Allows a user ID to follow another user.
 
         If the target user does not have public Tweets, this endpoint will send
@@ -1344,6 +1357,18 @@ class Client:
             user_auth=True
         )
 
+    def follow(self, target_user_id):
+        """Alias for :meth:`Client.follow_user`
+
+        .. deprecated:: 4.2
+            Use :meth:`Client.follow_user` instead.
+        """
+        warnings.warn(
+            "Client.follow is deprecated; use Client.follow_user instead.",
+            DeprecationWarning
+        )
+        self.follow_user(target_user_id)
+
     # Mutes
 
     def unmute(self, target_user_id):