Skip to content

Commit d36b4f1

Browse files
Fix handling sort type in subreddits
1 parent 29d5ee6 commit d36b4f1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/redditpythonapi/reddit.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __init__(
6666
async def subreddit_articles(
6767
self,
6868
subreddit: str,
69-
sort: ArticlesSortType | None = ArticlesSortType.HOT,
69+
sort: ArticlesSortType | None = None,
7070
time: ArticlesSortTime | None = None,
7171
limit: int | None = None,
7272
) -> list[Article]:
@@ -84,7 +84,8 @@ async def subreddit_articles(
8484
list[Article]: list of loaded articles from the given subreddit
8585
"""
8686
self._logger.info(f"Loading subreddit articles [{subreddit}] [{sort}] [{time}] [{limit}]")
87-
url = self._SUBREDDIT_ARTICLES_URL.format(subreddit=subreddit, sort=sort.name.lower())
87+
sort = sort or ArticlesSortType.HOT
88+
url = self._SUBREDDIT_ARTICLES_URL.format(subreddit=subreddit, sort=sort.value)
8889
params = self._prepare_params(limit=limit, time=time)
8990
return await self._get_articles(url, params)
9091

0 commit comments

Comments
 (0)