Skip to content

Commit acfe4c3

Browse files
Switch back to "Submission" alias
1 parent 6cf3792 commit acfe4c3

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ ArticlesSortType.CONTROVERSIAL
132132

133133
### Returned articles type
134134

135-
Returned type is a list of articles, where each article is a `dict`/`json` directly returned by official Reddit API.
135+
Returned type is a list of articles, where each article is a `Submission`.
136+
`Submission` is just an alias to `dict[str, Any]`.
137+
Returned data is directly representing JSON returned by official Reddit API, there are no modification to responses.
136138

137139
You can check official Reddit API documentation for:
138140
* users - https://www.reddit.com/dev/api/#GET_user_{username}_submitted

redditpythonapi/reddit.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
from httpx import AsyncClient, BasicAuth, Response
1212

13+
Submission = dict[str, Any]
14+
1315

1416
class ArticlesSortType(Enum):
1517
"""Enum with all viable sorting types"""
@@ -52,7 +54,7 @@ def __init__(
5254

5355
async def subreddit_articles(
5456
self, subreddit: str, limit: int, sort: ArticlesSortType
55-
) -> list[dict[str, Any]]:
57+
) -> list[Submission]:
5658
"""Get a list of Reddit articles from the given subreddit
5759
5860
Args:
@@ -61,7 +63,7 @@ async def subreddit_articles(
6163
sort (ArticlesSortType): sort type to use when loading articles
6264
6365
Returns:
64-
list[dict[str, Any]: list of loaded articles from the given subreddit
66+
list[Submission]: list of loaded articles from the given subreddit
6567
"""
6668
self._logger.info(f"Loading subreddit articles [{subreddit}] [{limit}] [{sort.name}]")
6769
url = self._SUBREDDIT_ARTICLES_URL.format(subreddit=subreddit, sort=sort.name.lower())
@@ -70,7 +72,7 @@ async def subreddit_articles(
7072

7173
async def user_articles(
7274
self, user: str, limit: int, sort: ArticlesSortType
73-
) -> list[dict[str, Any]]:
75+
) -> list[Submission]:
7476
"""Get a list of Reddit articles from the given Reddit user
7577
7678
Args:
@@ -79,7 +81,7 @@ async def user_articles(
7981
sort (ArticlesSortType): sort type to use when loading articles
8082
8183
Returns:
82-
list[dict[str, Any]: list of loaded articles from the Reddit user
84+
list[Submission]: list of loaded articles from the Reddit user
8385
"""
8486
self._logger.info(f"Loading user articles [{user}] [{limit}] [{sort.name}]")
8587
url = self._USER_ARTICLES_URL.format(user=user)
@@ -105,7 +107,7 @@ async def _request_access_token(self) -> Response:
105107
headers=self._auth_headers,
106108
)
107109

108-
async def _get_articles(self, url: str, params: dict[str, Any]) -> list[dict[str, Any]]:
110+
async def _get_articles(self, url: str, params: dict[str, Any]) -> list[Submission]:
109111
if self._access_token_expires_in <= time_ns():
110112
self._logger.info("Access token expired, requesting new one")
111113
await self._authorize()

0 commit comments

Comments
 (0)