Skip to content

Commit

Permalink
Add type hints for Client bookmarks methods
Browse files Browse the repository at this point in the history
Add type hints for Client.remove_bookmark, Client.get_bookmarks, and Client.bookmark
  • Loading branch information
Harmon758 committed Apr 5, 2022
1 parent 0d502d3 commit 647df26
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions tweepy/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ def _get_oauth_2_authenticating_user_id(self, access_token):

# Bookmarks

def remove_bookmark(self, tweet_id):
def remove_bookmark(
self, tweet_id: int | str
) -> JSON | requests.Response | Response:
"""Allows a user or authenticated user ID to remove a Bookmark of a
Tweet.
Expand All @@ -300,7 +302,7 @@ def remove_bookmark(self, tweet_id):
Parameters
----------
tweet_id : int | str
tweet_id
The ID of the Tweet that you would like the ``id`` to remove a
Bookmark of.
Expand All @@ -309,10 +311,6 @@ def remove_bookmark(self, tweet_id):
TypeError
If the access token isn't set
Returns
-------
dict | requests.Response | Response
References
----------
https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/api-reference/delete-users-id-bookmarks-tweet_id
Expand All @@ -324,7 +322,9 @@ def remove_bookmark(self, tweet_id):
"DELETE", route
)

def get_bookmarks(self, **params):
def get_bookmarks(
self, **params: _ParamsMappingValueType
) -> JSON | requests.Response | Response:
"""get_bookmarks( \
*, expansions=None, max_results=None, media_fields=None, \
pagination_token=None, place_fields=None, poll_fields=None, \
Expand Down Expand Up @@ -372,10 +372,6 @@ def get_bookmarks(self, **params):
TypeError
If the access token isn't set
Returns
-------
dict | requests.Response | Response
References
----------
https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/api-reference/get-users-id-bookmarks
Expand All @@ -392,7 +388,9 @@ def get_bookmarks(self, **params):
), data_type=Tweet
)

def bookmark(self, tweet_id):
def bookmark(
self, tweet_id: int | str
) -> JSON | requests.Response | Response:
"""Causes the authenticating user to Bookmark the target Tweet provided
in the request body.
Expand All @@ -406,7 +404,7 @@ def bookmark(self, tweet_id):
Parameters
----------
tweet_id : int | str
tweet_id
The ID of the Tweet that you would like the user ``id`` to
Bookmark.
Expand All @@ -415,10 +413,6 @@ def bookmark(self, tweet_id):
TypeError
If the access token isn't set
Returns
-------
dict | requests.Response | Response
References
----------
https://developer.twitter.com/en/docs/twitter-api/tweets/bookmarks/api-reference/post-users-id-bookmarks
Expand Down

0 comments on commit 647df26

Please sign in to comment.