From: Harmon Date: Fri, 25 Feb 2022 22:48:44 +0000 (-0600) Subject: Use | operator for optional types in documentation X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=538ccc217ba2fd72dd3524bfc6e951d12df1fd6e;p=tweepy.git Use | operator for optional types in documentation --- diff --git a/tweepy/asynchronous/streaming.py b/tweepy/asynchronous/streaming.py index 9e1f354..1932a86 100644 --- a/tweepy/asynchronous/streaming.py +++ b/tweepy/asynchronous/streaming.py @@ -34,16 +34,16 @@ class AsyncStream: Twitter API Access Token access_token_secret: str Twitter API Access Token Secret - max_retries: Optional[int] + max_retries: int | None Number of times to attempt to (re)connect the stream. - proxy: Optional[str] + proxy: str | None Proxy URL Attributes ---------- - session : Optional[aiohttp.ClientSession] + session : aiohttp.ClientSession | None Aiohttp client session used to connect to the API - task : Optional[asyncio.Task] + task : asyncio.Task | None The task running the stream user_agent : str User agent used when connecting to the API @@ -152,19 +152,19 @@ class AsyncStream: Parameters ---------- - follow: Optional[list[int | str]] + follow: list[int | str] | None A list of user IDs, indicating the users to return statuses for in the stream. See https://developer.twitter.com/en/docs/twitter-api/v1/tweets/filter-realtime/guides/basic-stream-parameters for more information. - track: Optional[list[str]] + track: list[str] | None Keywords to track. Phrases of keywords are specified by a list. See https://developer.twitter.com/en/docs/tweets/filter-realtime/guides/basic-stream-parameters for more information. - locations: Optional[list[float]] + locations: list[float] | None Specifies a set of bounding boxes to track. See https://developer.twitter.com/en/docs/tweets/filter-realtime/guides/basic-stream-parameters for more information. - filter_level : Optional[str] + filter_level : str | None Setting this parameter to one of none, low, or medium will set the minimum value of the filter_level Tweet attribute required to be included in the stream. The default value is none, which includes @@ -173,14 +173,14 @@ class AsyncStream: When displaying a stream of Tweets to end users (dashboards or live feeds at a presentation or conference, for example) it is suggested that you set this value to medium. - languages : Optional[list[str]] + languages : list[str] | None Setting this parameter to a comma-separated list of `BCP 47`_ language identifiers corresponding to any of the languages listed on Twitter’s `advanced search`_ page will only return Tweets that have been detected as being written in the specified languages. For example, connecting with language=en will only stream Tweets detected to be in the English language. - stall_warnings: Optional[bool] + stall_warnings: bool | None Specifies whether stall warnings should be delivered. See https://developer.twitter.com/en/docs/tweets/filter-realtime/guides/basic-stream-parameters for more information. @@ -240,14 +240,14 @@ class AsyncStream: Parameters ---------- - languages : Optional[list[str]] + languages : list[str] | None Setting this parameter to a comma-separated list of `BCP 47`_ language identifiers corresponding to any of the languages listed on Twitter’s `advanced search`_ page will only return Tweets that have been detected as being written in the specified languages. For example, connecting with language=en will only stream Tweets detected to be in the English language. - stall_warnings: Optional[bool] + stall_warnings: bool | None Specifies whether stall warnings should be delivered. See https://developer.twitter.com/en/docs/tweets/filter-realtime/guides/basic-stream-parameters for more information. diff --git a/tweepy/client.py b/tweepy/client.py index ec849c5..42ab503 100644 --- a/tweepy/client.py +++ b/tweepy/client.py @@ -194,15 +194,15 @@ class Client(BaseClient): Parameters ---------- - bearer_token : Optional[str] + bearer_token : str | None Twitter API Bearer Token - consumer_key : Optional[str] + consumer_key : str | None Twitter API Consumer Key - consumer_secret : Optional[str] + consumer_secret : str | None Twitter API Consumer Secret - access_token : Optional[str] + access_token : str | None Twitter API Access Token - access_token_secret : Optional[str] + access_token_secret : str | None Twitter API Access Token Secret return_type : Type[dict | requests.Response | Response] Type to return from requests to the API @@ -497,40 +497,40 @@ class Client(BaseClient): Parameters ---------- - direct_message_deep_link : Optional[str] + direct_message_deep_link : str | None `Tweets a link directly to a Direct Message conversation`_ with an account. - for_super_followers_only : Optional[bool] + for_super_followers_only : bool | None Allows you to Tweet exclusively for `Super Followers`_. - place_id : Optional[str] + place_id : str | None Place ID being attached to the Tweet for geo location. - media_ids : Optional[list[int | str]] + media_ids : list[int | str] | None A list of Media IDs being attached to the Tweet. This is only required if the request includes the ``tagged_user_ids``. - media_tagged_user_ids : Optional[list[int | str]] + media_tagged_user_ids : list[int | str] | None A list of User IDs being tagged in the Tweet with Media. If the user you're tagging doesn't have photo-tagging enabled, their names won't show up in the list of tagged users even though the Tweet is successfully created. - poll_duration_minutes : Optional[int] + poll_duration_minutes : int | None Duration of the poll in minutes for a Tweet with a poll. This is only required if the request includes ``poll.options``. - poll_options : Optional[list[str]] + poll_options : list[str] | None A list of poll options for a Tweet with a poll. - quote_tweet_id : Optional[int | str] + quote_tweet_id : int | str | None Link to the Tweet being quoted. - exclude_reply_user_ids : Optional[list[int | str]] + exclude_reply_user_ids : list[int | str] | None A list of User IDs to be excluded from the reply Tweet thus removing a user from a thread. - in_reply_to_tweet_id : Optional[int | str] + in_reply_to_tweet_id : int | str | None Tweet ID of the Tweet being replied to. Please note that ``in_reply_to_tweet_id`` needs to be in the request if ``exclude_reply_user_ids`` is present. - reply_settings : Optional[str] + reply_settings : str | None `Settings`_ to indicate who can reply to the Tweet. Limited to "mentionedUsers" and "following". If the field isn’t specified, it will default to everyone. - text : Optional[str] + text : str | None Text of the Tweet being created. This field is required if ``media.media_ids`` is not present. user_auth : bool diff --git a/tweepy/streaming.py b/tweepy/streaming.py index 93e630f..4d527de 100644 --- a/tweepy/streaming.py +++ b/tweepy/streaming.py @@ -221,7 +221,7 @@ class Stream(BaseStream): stream max_retries : int Max number of times to retry connecting the stream - proxy : Optional[str] + proxy : str | None URL of the proxy to use when connecting to the stream verify : bool | str Either a boolean, in which case it controls whether to verify the @@ -234,7 +234,7 @@ class Stream(BaseStream): Whether there's currently a stream running session : :class:`requests.Session` Requests Session used to connect to the stream - thread : Optional[:class:`threading.Thread`] + thread : :class:`threading.Thread` | None Thread used to run the stream user_agent : str User agent used when connecting to the stream @@ -267,13 +267,13 @@ class Stream(BaseStream): Parameters ---------- - follow : Optional[list[int | str]] + follow : list[int | str] | None User IDs, indicating the users to return statuses for in the stream - track : Optional[list[str]] + track : list[str] | None Keywords to track - locations : Optional[list[float]] + locations : list[float] | None Specifies a set of bounding boxes to track - filter_level : Optional[str] + filter_level : str | None Setting this parameter to one of none, low, or medium will set the minimum value of the filter_level Tweet attribute required to be included in the stream. The default value is none, which includes @@ -282,7 +282,7 @@ class Stream(BaseStream): When displaying a stream of Tweets to end users (dashboards or live feeds at a presentation or conference, for example) it is suggested that you set this value to medium. - languages : Optional[list[str]] + languages : list[str] | None Setting this parameter to a comma-separated list of `BCP 47`_ language identifiers corresponding to any of the languages listed on Twitter’s `advanced search`_ page will only return Tweets that @@ -301,7 +301,7 @@ class Stream(BaseStream): Returns ------- - Optional[threading.Thread] + threading.Thread | None The thread if ``threaded`` is set to ``True``, else ``None`` References @@ -347,7 +347,7 @@ class Stream(BaseStream): Parameters ---------- - languages : Optional[list[str]] + languages : list[str] | None Setting this parameter to a comma-separated list of `BCP 47`_ language identifiers corresponding to any of the languages listed on Twitter’s `advanced search`_ page will only return Tweets that @@ -361,7 +361,7 @@ class Stream(BaseStream): Returns ------- - Optional[threading.Thread] + threading.Thread | None The thread if ``threaded`` is set to ``True``, else ``None`` References @@ -533,7 +533,7 @@ class StreamingClient(BaseClient, BaseStream): stream max_retries : int Max number of times to retry connecting the stream - proxy : Optional[str] + proxy : str | None URL of the proxy to use when connecting to the stream verify : bool | str Either a boolean, in which case it controls whether to verify the @@ -546,7 +546,7 @@ class StreamingClient(BaseClient, BaseStream): Whether there's currently a stream running session : :class:`requests.Session` Requests Session used to connect to the stream - thread : Optional[:class:`threading.Thread`] + thread : :class:`threading.Thread` | None Thread used to run the stream user_agent : str User agent used when connecting to the stream @@ -682,7 +682,7 @@ class StreamingClient(BaseClient, BaseStream): Parameters ---------- - backfill_minutes : Optional[int] + backfill_minutes : int | None By passing this parameter, you can request up to five (5) minutes worth of streaming data that you might have missed during a disconnection to be delivered to you upon reconnection. The @@ -716,7 +716,7 @@ class StreamingClient(BaseClient, BaseStream): Returns ------- - Optional[threading.Thread] + threading.Thread | None The thread if ``threaded`` is set to ``True``, else ``None`` References @@ -784,7 +784,7 @@ class StreamingClient(BaseClient, BaseStream): Parameters ---------- - backfill_minutes : Optional[int] + backfill_minutes : int | None By passing this parameter, you can request up to five (5) minutes worth of streaming data that you might have missed during a disconnection to be delivered to you upon reconnection. The @@ -818,7 +818,7 @@ class StreamingClient(BaseClient, BaseStream): Returns ------- - Optional[threading.Thread] + threading.Thread | None The thread if ``threaded`` is set to ``True``, else ``None`` References @@ -943,7 +943,7 @@ class StreamRule(NamedTuple): Parameters ---------- - value : Optional[str] + value : str | None The rule text. If you are using a `Standard Project`_ at the Basic `access level`_, you can use the basic set of `operators`_, can submit up to 25 concurrent rules, and can submit rules up to 512 characters @@ -951,11 +951,11 @@ class StreamRule(NamedTuple): access level, you can use all available operators, can submit up to 1,000 concurrent rules, and can submit rules up to 1,024 characters long. - tag : Optional[str] + tag : str | None The tag label. This is a free-form text you can use to identify the rules that matched a specific Tweet in the streaming response. Tags can be the same across rules. - id : Optional[str] + id : str | None Unique identifier of this rule. This is returned as a string.