Update and improve documentation for API.update_profile_image
authorHarmon <Harmon758@gmail.com>
Sat, 10 Apr 2021 14:32:24 +0000 (09:32 -0500)
committerHarmon <Harmon758@gmail.com>
Sat, 10 Apr 2021 14:32:24 +0000 (09:32 -0500)
Automatically use docstring for documentation
Improve method and documentation order
Add documentation for file, include_entities, and skip_status parameters
Improve documentation for filename parameter by using substitution

docs/api.rst
tweepy/api.py

index 2419d07356bb51451b74b5668cfbd62f8ef72857..a7e6b22a4c8032d16688f518ccca10dc7ed56518 100644 (file)
@@ -162,6 +162,8 @@ Manage account settings and profile
 
 .. automethod:: API.update_profile_banner
 
+.. automethod:: API.update_profile_image
+
 
 Direct Message Methods
 ----------------------
@@ -233,15 +235,6 @@ Account Methods
    :rtype: :class:`JSON` object
 
 
-.. method:: API.update_profile_image(filename)
-
-   Update the authenticating user's profile image. Valid formats: GIF, JPG, or
-   PNG
-
-   :param filename: local path to image file to upload. Not a remote URL!
-   :rtype: :class:`User` object
-
-
 Block Methods
 -------------
 
index a4121972193da96228486b17a7c4f236d3151d0c..72b6d60d5198a0375b27b3862478d8a8ea9868df 100644 (file)
@@ -1945,6 +1945,33 @@ class API:
             ), files=files, **kwargs
         )
 
+    @payload('user')
+    def update_profile_image(self, filename, *, file=None, **kwargs):
+        """update_profile_image(filename, *, file, include_entities, \
+                                skip_status)
+
+        Update the authenticating user's profile image. Valid formats: GIF,
+        JPG, or PNG
+
+        :param filename: |filename|
+        :param file: |file|
+        :param include_entities: |include_entities|
+        :param skip_status: |skip_status|
+
+        :rtype: :class:`User` object
+
+        :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_image
+        """
+        if file is not None:
+            files = {'image': (filename, file)}
+        else:
+            files = {'image': open(filename, 'rb')}
+        return self.request(
+            'POST', 'account/update_profile_image', endpoint_parameters=(
+                'include_entities', 'skip_status'
+            ), files=files, **kwargs
+        )
+
     def media_upload(self, filename, *, file=None, chunked=False,
                      media_category=None, additional_owners=None, **kwargs):
         """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/media/upload-media/overview
@@ -2184,20 +2211,6 @@ class API:
             ), use_cache=False, **kwargs
         )
 
-    @payload('user')
-    def update_profile_image(self, filename, *, file=None, **kwargs):
-        """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_image
-        """
-        if file is not None:
-            files = {'image': (filename, file)}
-        else:
-            files = {'image': open(filename, 'rb')}
-        return self.request(
-            'POST', 'account/update_profile_image', endpoint_parameters=(
-                'include_entities', 'skip_status'
-            ), files=files, **kwargs
-        )
-
     @payload('user')
     def create_block(self, **kwargs):
         """ :reference: https://developer.twitter.com/en/docs/twitter-api/v1/accounts-and-users/mute-block-report-users/api-reference/post-blocks-create