Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ updates:
- package-ecosystem: uv
directory: /
schedule:
interval: cron
cronjob: "46 17 * * *"
interval: weekly
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ asyncprawcore follows `semantic versioning <https://semver.org/>`_.
Unreleased
----------

**Changed**

- Improved exception message when ``asyncio.TimeoutError`` is raised.

3.0.2 (2025/08/06)
------------------

Expand Down
4 changes: 2 additions & 2 deletions asyncprawcore/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ async def revoke_token(self, token: str, token_type: str | None = None) -> None:
if token_type is not None:
data["token_type_hint"] = token_type
url = self._requestor.reddit_url + const.REVOKE_TOKEN_PATH
async with self._post(url=url, **data) as _:
pass # The response is not used.
async with self._post(url=url, **data):
pass


class BaseAuthorizer:
Expand Down
5 changes: 4 additions & 1 deletion asyncprawcore/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

import asyncio
from typing import TYPE_CHECKING, Any
from urllib.parse import urlparse

Expand Down Expand Up @@ -56,7 +57,9 @@ def __init__(
self.original_exception = original_exception
self.request_args = request_args
self.request_kwargs = request_kwargs
super().__init__(f"error with request {original_exception}")
super().__init__(
f"error with request {'TimeoutError' if isinstance(original_exception, asyncio.TimeoutError) else original_exception}"
)


class ResponseException(AsyncPrawcoreException):
Expand Down
9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
build-backend = "flit_core.buildapi"
requires = ["flit_core >=3.4,<4"]
build-backend = "hatchling.build"
requires = ["hatchling"]

[dependency-groups]
dev = [
Expand Down Expand Up @@ -61,15 +61,18 @@ requires-python = ">=3.9"
"Issue Tracker" = "https://github.com/praw-dev/asyncprawcore/issues"
"Source Code" = "https://github.com/praw-dev/asyncprawcore"

[tool.hatch.version]
path = "asyncprawcore/__init__.py"

[tool.pytest.ini_options]
asyncio_mode = "auto"
filterwarnings = "ignore::DeprecationWarning"
testpaths = "tests"

[tool.ruff]
include = [
"examples/*.py",
"asyncprawcore/*.py",
"examples/*.py",
"tests/*.py"
]
line-length = 120
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/test_requestor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,18 @@ async def test_request__wrap_request_exceptions(self, mock_session):
assert exception is exception_info.value.original_exception
assert exception_info.value.request_args == ("get", "http://a.b")
assert exception_info.value.request_kwargs == {"data": "bar"}

@patch("aiohttp.ClientSession")
async def test_request__wrap_request_exceptions__timeout(self, mock_session):
exception = asyncio.TimeoutError()
session_instance = mock_session.return_value
session_instance.request.side_effect = exception
requestor = asyncprawcore.Requestor("asyncprawcore:test (by u/Lil_SpazJoekp)")
with pytest.raises(asyncprawcore.RequestException) as exception_info:
async with requestor.request("get", "http://a.b", data="bar") as _:
pass # pragma: no cover
assert isinstance(exception_info.value, RequestException)
assert exception is exception_info.value.original_exception
assert str(exception_info.value) == "error with request TimeoutError"
assert exception_info.value.request_args == ("get", "http://a.b")
assert exception_info.value.request_kwargs == {"data": "bar"}
Loading