Skip to content

Commit

Permalink
Fix coverage issues
Browse files Browse the repository at this point in the history
(cherry picked from commit praw-dev/prawcore@83aa52c)
  • Loading branch information
LilSpazJoekp committed Nov 26, 2023
1 parent c94f216 commit ce87607
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .coveragerc
@@ -0,0 +1,5 @@
[report]
exclude_lines =
@abstract
if TYPE_CHECKING:
pragma: no cover
2 changes: 1 addition & 1 deletion asyncprawcore/auth.py
Expand Up @@ -22,7 +22,7 @@
from .codes import codes
from .exceptions import InvalidInvocation, OAuthException, ResponseException

if TYPE_CHECKING: # pragma: no cover
if TYPE_CHECKING:
from asyncprawcore.requestor import Requestor


Expand Down
2 changes: 1 addition & 1 deletion asyncprawcore/exceptions.py
Expand Up @@ -3,7 +3,7 @@
from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
from urllib.parse import urlparse

if TYPE_CHECKING: # pragma: no cover
if TYPE_CHECKING:
from aiohttp import ClientResponse


Expand Down
2 changes: 1 addition & 1 deletion asyncprawcore/rate_limit.py
Expand Up @@ -4,7 +4,7 @@
import time
from typing import TYPE_CHECKING, Any, Awaitable, Callable, Dict, Mapping, Optional

if TYPE_CHECKING: # pragma: no cover
if TYPE_CHECKING:
from aiohttp import ClientResponse

log = logging.getLogger(__package__)
Expand Down
2 changes: 1 addition & 1 deletion asyncprawcore/requestor.py
Expand Up @@ -7,7 +7,7 @@
from .const import TIMEOUT, __version__
from .exceptions import InvalidInvocation, RequestException

if TYPE_CHECKING: # pragma: no cover
if TYPE_CHECKING:
from asyncio import AbstractEventLoop

from .sessions import Session
Expand Down
2 changes: 1 addition & 1 deletion asyncprawcore/sessions.py
Expand Up @@ -30,7 +30,7 @@
from .rate_limit import RateLimiter
from .util import authorization_error_class

if TYPE_CHECKING: # pragma: no cover
if TYPE_CHECKING:
from io import BufferedReader

from aiofiles.threadpool.binary import AsyncBufferedReader
Expand Down
7 changes: 6 additions & 1 deletion asyncprawcore/util.py
@@ -1,14 +1,19 @@
"""Provide utility for the asyncprawcore package."""
from typing import TYPE_CHECKING, Union

from .exceptions import Forbidden, InsufficientScope, InvalidToken

if TYPE_CHECKING:
from aiohttp import ClientResponse

_auth_error_mapping = {
403: Forbidden,
"insufficient_scope": InsufficientScope,
"invalid_token": InvalidToken,
}


def authorization_error_class(response):
def authorization_error_class(response: "ClientResponse") -> Union[InvalidToken, Forbidden, InsufficientScope]:
"""Return an exception instance that maps to the OAuth Error.
:param response: The HTTP response containing a www-authenticate error.
Expand Down

0 comments on commit ce87607

Please sign in to comment.