Skip to content

Commit

Permalink
🎨 reformat files
Browse files Browse the repository at this point in the history
  • Loading branch information
Ousret committed Oct 24, 2024
1 parent d17b7b0 commit 6e0bec9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 18 deletions.
21 changes: 13 additions & 8 deletions prawcore/_async/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import time
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any, Callable, Awaitable
from typing import TYPE_CHECKING, Any, Awaitable, Callable

from niquests import Request, Response
from niquests.status_codes import codes
Expand Down Expand Up @@ -80,8 +80,8 @@ def authorize_url(
:raises: :class:`.InvalidInvocation` if ``redirect_uri`` is not provided, if
``implicit`` is ``True`` and an authenticator other than
:class:`.AsyncUntrustedAuthenticator` is used, or ``implicit`` is ``True`` and
``duration`` is ``"permanent"``.
:class:`.AsyncUntrustedAuthenticator` is used, or ``implicit`` is ``True``
and ``duration`` is ``"permanent"``.
"""
if self.redirect_uri is None:
Expand Down Expand Up @@ -237,22 +237,27 @@ def __init__(
self,
authenticator: AsyncBaseAuthenticator,
*,
post_refresh_callback: Callable[[AsyncAuthorizer], Awaitable[None]] | None = None,
pre_refresh_callback: Callable[[AsyncAuthorizer], Awaitable[None]] | None = None,
post_refresh_callback: (
Callable[[AsyncAuthorizer], Awaitable[None]] | None
) = None,
pre_refresh_callback: (
Callable[[AsyncAuthorizer], Awaitable[None]] | None
) = None,
refresh_token: str | None = None,
):
"""Represent a single authorization to Reddit's API.
:param authenticator: An instance of a subclass of :class:`.AsyncBaseAuthenticator`.
:param authenticator: An instance of a subclass of
:class:`.AsyncBaseAuthenticator`.
:param post_refresh_callback: When a single-argument function is passed, the
function will be called prior to refreshing the access and refresh tokens.
The argument to the callback is the :class:`.AsyncAuthorizer` instance. This
callback can be used to inspect and modify the attributes of the
:class:`.AsyncAuthorizer`.
:param pre_refresh_callback: When a single-argument function is passed, the
function will be called after refreshing the access and refresh tokens. The
argument to the callback is the :class:`.AsyncAuthorizer` instance. This callback
can be used to inspect and modify the attributes of the
argument to the callback is the :class:`.AsyncAuthorizer` instance. This
callback can be used to inspect and modify the attributes of the
:class:`.AsyncAuthorizer`.
:param refresh_token: Enables the ability to refresh the authorization.
Expand Down
2 changes: 1 addition & 1 deletion prawcore/_async/rate_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import logging
import time
from typing import TYPE_CHECKING, Any, Callable, Mapping, Awaitable
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Mapping

if TYPE_CHECKING:
from niquests.models import Response
Expand Down
4 changes: 3 additions & 1 deletion prawcore/_async/requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ async def request(
) -> niquests.Response:
"""Issue the HTTP request capturing any errors that may occur."""
try:
return await self._http.request(*args, timeout=timeout or self.timeout, **kwargs)
return await self._http.request(
*args, timeout=timeout or self.timeout, **kwargs
)
except Exception as exc: # noqa: BLE001
raise RequestException(exc, args, kwargs) from exc
4 changes: 2 additions & 2 deletions prawcore/_async/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
from niquests.exceptions import ChunkedEncodingError, ConnectionError, ReadTimeout
from niquests.status_codes import codes

from .auth import AsyncBaseAuthorizer
from ..const import TIMEOUT, WINDOW_SIZE
from ..exceptions import (
BadJSON,
Expand All @@ -32,8 +31,9 @@
UnavailableForLegalReasons,
URITooLong,
)
from .rate_limit import AsyncRateLimiter
from ..util import authorization_error_class
from .auth import AsyncBaseAuthorizer
from .rate_limit import AsyncRateLimiter

if TYPE_CHECKING:
from niquests.models import Response
Expand Down
11 changes: 5 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ line-length = 88
profile = 'black'
skip_glob = '.venv*'

[tool.pytest.ini_options]
# this avoids pytest loading betamax+Requests at boot.
# this allows us to patch betamax and makes it use Niquests instead.
addopts = "-p no:pytest-betamax"

[tool.ruff]
target-version = "py38"
include = [
Expand Down Expand Up @@ -129,9 +134,3 @@ suppress-none-returning = true

[tool.ruff.lint.per-file-ignores]
"__init__.py" = ["F401"]


[tool.pytest.ini_options]
# this avoids pytest loading betamax+Requests at boot.
# this allows us to patch betamax and makes it use Niquests instead.
addopts = "-p no:pytest-betamax"

0 comments on commit 6e0bec9

Please sign in to comment.