Skip to content

Commit

Permalink
Format with docstrfmt
Browse files Browse the repository at this point in the history
Signed-off-by: LilSpazJoekp <15524072+LilSpazJoekp@users.noreply.github.com>
  • Loading branch information
LilSpazJoekp committed Dec 17, 2020
1 parent bdc861b commit 7839732
Show file tree
Hide file tree
Showing 153 changed files with 2,339 additions and 2,370 deletions.
16 changes: 10 additions & 6 deletions asyncpraw/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,11 @@ def __init__(
):
"""Initialize an instance of RedditAPIException.
:param items: Either a list of instances of :class:`.RedditErrorItem`
or a list containing lists of unformed errors.
:param items: Either a list of instances of :class:`.RedditErrorItem` or a list
containing lists of unformed errors.
:param optional_args: Takes the second and third arguments that
:class:`.APIException` used to take.
"""
if isinstance(items, str):
items = [[items, *optional_args]]
Expand Down Expand Up @@ -201,8 +202,9 @@ def __init__(self, url: str, message: str = "Invalid URL: {}"):
"""Initialize the class.
:param url: The invalid URL.
:param message: The message to display. Must contain a format
identifier (``{}`` or ``{0}``). (default: ``"Invalid URL: {}"``)
:param message: The message to display. Must contain a format identifier (``{}``
or ``{0}``). (default: ``"Invalid URL: {}"``)
"""
super().__init__(message.format(url))

Expand Down Expand Up @@ -257,8 +259,10 @@ def __init__(self, message: str, exception: Optional[Exception]):
:param message: The exception message.
:param exception: The exception thrown by the websocket library.
.. note:: This parameter is deprecated. It will be removed in Async PRAW
8.0.
.. note::
This parameter is deprecated. It will be removed in Async PRAW 8.0.
"""
super().__init__(message)
self._original_exception = exception
Expand Down
63 changes: 30 additions & 33 deletions asyncpraw/models/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,19 @@ def limits(self) -> Dict[str, Optional[Union[str, int]]]:
The keys are:
:remaining: The number of requests remaining to be made in the
current rate limit window.
:reset_timestamp: A unix timestamp providing an upper bound on when the
rate limit counters will reset.
:used: The number of requests made in the current rate limit
window.
:remaining: The number of requests remaining to be made in the current rate
limit window.
:reset_timestamp: A unix timestamp providing an upper bound on when the rate
limit counters will reset.
:used: The number of requests made in the current rate limit window.
All values are initially ``None`` as these values are set in response
to issued requests.
All values are initially ``None`` as these values are set in response to issued
requests.
The ``reset_timestamp`` value is an upper bound as the real timestamp
is computed on Reddit's end in preparation for sending the
response. This value may change slightly within a given window due to
slight changes in response times and rounding.
The ``reset_timestamp`` value is an upper bound as the real timestamp is
computed on Reddit's end in preparation for sending the response. This value may
change slightly within a given window due to slight changes in response times
and rounding.
"""
data = self._reddit._core._rate_limiter
Expand Down Expand Up @@ -64,16 +63,16 @@ def implicit(self, access_token: str, expires_in: int, scope: str) -> None:
"""Set the active authorization to be an implicit authorization.
:param access_token: The access_token obtained from Reddit's callback.
:param expires_in: The number of seconds the ``access_token`` is valid
for. The origin of this value was returned from Reddit's callback.
You may need to subtract an offset before passing in this number to
account for a delay between when Reddit prepared the response, and
when you make this function call.
:param scope: A space-delimited string of Reddit OAuth2 scope names as
returned from Reddit's callback.
:param expires_in: The number of seconds the ``access_token`` is valid for. The
origin of this value was returned from Reddit's callback. You may need to
subtract an offset before passing in this number to account for a delay
between when Reddit prepared the response, and when you make this function
call.
:param scope: A space-delimited string of Reddit OAuth2 scope names as returned
from Reddit's callback.
:raises: :class:`.InvalidImplicitAuth` if :class:`.Reddit` was
initialized for a non-installed application type.
:raises: :class:`.InvalidImplicitAuth` if :class:`.Reddit` was initialized for a
non-installed application type.
"""
authenticator = self._reddit._read_only_core._authorizer._authenticator
Expand Down Expand Up @@ -106,18 +105,16 @@ def url(
:param scopes: A list of OAuth scopes to request authorization for.
:param state: A string that will be reflected in the callback to
``redirect_uri``. This value should be temporarily unique to the
client for whom the URL was generated for.
:param duration: Either ``permanent`` or ``temporary`` (default:
permanent). ``temporary`` authorizations generate access tokens
that last only 1 hour. ``permanent`` authorizations additionally
generate a refresh token that can be indefinitely used to generate
new hour-long access tokens. This value is ignored when
``implicit=True``.
:param implicit: For **installed** applications, this value can be set
to use the implicit, rather than the code flow. When True, the
``duration`` argument has no effect as only temporary tokens can be
retrieved.
``redirect_uri``. This value should be temporarily unique to the client for
whom the URL was generated for.
:param duration: Either ``permanent`` or ``temporary`` (default: permanent).
``temporary`` authorizations generate access tokens that last only 1 hour.
``permanent`` authorizations additionally generate a refresh token that can
be indefinitely used to generate new hour-long access tokens. This value is
ignored when ``implicit=True``.
:param implicit: For **installed** applications, this value can be set to use
the implicit, rather than the code flow. When True, the ``duration``
argument has no effect as only temporary tokens can be retrieved.
"""
authenticator = self._reddit._read_only_core._authorizer._authenticator
Expand Down
7 changes: 3 additions & 4 deletions asyncpraw/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ class AsyncPRAWBase:
def _safely_add_arguments(argument_dict, key, **new_arguments):
"""Replace argument_dict[key] with a deepcopy and update.
This method is often called when new parameters need to be added to a
request. By calling this method and adding the new or updated
parameters we can insure we don't modify the dictionary passed in by
the caller.
This method is often called when new parameters need to be added to a request.
By calling this method and adding the new or updated parameters we can insure we
don't modify the dictionary passed in by the caller.
"""
value = deepcopy(argument_dict[key]) if key in argument_dict else {}
Expand Down
11 changes: 5 additions & 6 deletions asyncpraw/models/comment_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def __getitem__(self, index: int):
comments = await submission.comments()
first_comment = comments[0]
Alternatively, the presence of this method enables one to iterate over
all top_level comments, like so:
Alternatively, the presence of this method enables one to iterate over all
top_level comments, like so:
.. code-block:: python
Expand Down Expand Up @@ -79,10 +79,9 @@ def __init__(
):
"""Initialize a CommentForest instance.
:param submission: An instance of :class:`~.Subreddit` that is the
parent of the comments.
:param comments: Initialize the Forest with a list of comments
(default: None).
:param submission: An instance of :class:`~.Subreddit` that is the parent of the
comments.
:param comments: Initialize the Forest with a list of comments (default: None).
"""
self._comments = comments
Expand Down
13 changes: 6 additions & 7 deletions asyncpraw/models/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,23 @@ def info(self, ids: List[str]) -> AsyncGenerator[LiveThread, None]:
:param ids: A list of IDs for a live thread.
:returns: A generator that yields :class:`.LiveThread` instances.
Live threads that cannot be matched will not be generated.
Requests will be issued in batches for each 100 IDs.
Live threads that cannot be matched will not be generated. Requests will be
issued in batches for each 100 IDs.
.. note::
This method doesn't support IDs for live updates.
.. warning::
Unlike :meth:`.Reddit.info`, the output of this method
may not reflect the order of input.
Unlike :meth:`.Reddit.info`, the output of this method may not reflect the
order of input.
Usage:
.. code-block:: python
ids = ["3rgnbke2rai6hen7ciytwcxadi",
"sw7bubeycai6hey4ciytwamw3a",
"t8jnufucss07"]
ids = ["3rgnbke2rai6hen7ciytwcxadi", "sw7bubeycai6hey4ciytwamw3a", "t8jnufucss07"]
async for thread in reddit.live.info(ids):
print(thread.title)
Expand Down
14 changes: 8 additions & 6 deletions asyncpraw/models/inbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,7 @@ def sent(
Additional keyword arguments are passed in the initialization of
:class:`.ListingGenerator`.
For example, to output the recipient of the most recent 15 messages
try:
For example, to output the recipient of the most recent 15 messages try:
.. code-block:: python
Expand All @@ -219,8 +218,8 @@ def stream(
) -> AsyncGenerator[Union["Comment", "Message"], None]:
"""Yield new inbox items as they become available.
Items are yielded oldest first. Up to 100 historical items will
initially be returned.
Items are yielded oldest first. Up to 100 historical items will initially be
returned.
Keyword arguments are passed to :func:`.stream_generator`.
Expand Down Expand Up @@ -291,8 +290,10 @@ def unread(
:param mark_read: Marks the inbox as read (default: False).
.. note:: This only marks the inbox as read not the messages. Use
:meth:`.Inbox.mark_read` to mark the messages.
.. note::
This only marks the inbox as read not the messages. Use
:meth:`.Inbox.mark_read` to mark the messages.
Additional keyword arguments are passed in the initialization of
:class:`.ListingGenerator`.
Expand All @@ -302,6 +303,7 @@ def unread(
.. code-block:: python
from asyncpraw.models import Comment
async for item in reddit.inbox.unread(limit=None):
if isinstance(item, Comment):
print(item.author)
Expand Down
4 changes: 2 additions & 2 deletions asyncpraw/models/list/trophy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
class TrophyList(BaseList):
"""A list of trophies.
This class is solely used to parse responses from reddit,
so end users should not use this class directly.
This class is solely used to parse responses from reddit, so end users should not
use this class directly.
"""

Expand Down
21 changes: 11 additions & 10 deletions asyncpraw/models/listing/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
class ListingGenerator(AsyncPRAWBase, AsyncIterator):
"""Instances of this class generate :class:`.RedditBase` instances.
.. warning:: This class should not be directly utilized. Instead you will
find a number of methods that return instances of the class:
.. warning::
https://asyncpraw.readthedocs.io/en/latest/search.html?q=ListingGenerator
This class should not be directly utilized. Instead you will find a number of
methods that return instances of the class:
https://asyncpraw.readthedocs.io/en/latest/search.html?q=ListingGenerator
"""

Expand All @@ -30,13 +32,12 @@ def __init__(
:param reddit: An instance of :class:`.Reddit`.
:param url: A URL returning a reddit listing.
:param limit: The number of content entries to fetch. If ``limit`` is
None, then fetch as many entries as possible. Most of reddit's
listings contain a maximum of 1000 items, and are returned 100 at a
time. This class will automatically issue all necessary
requests (default: 100).
:param params: A dictionary containing additional query string
parameters to send with the request.
:param limit: The number of content entries to fetch. If ``limit`` is None, then
fetch as many entries as possible. Most of reddit's listings contain a
maximum of 1000 items, and are returned 100 at a time. This class will
automatically issue all necessary requests (default: 100).
:param params: A dictionary containing additional query string parameters to
send with the request.
"""
super().__init__(reddit, _data=None)
Expand Down
Loading

0 comments on commit 7839732

Please sign in to comment.