Skip to content

Commit

Permalink
Remove Subreddits.search_by_topic method
Browse files Browse the repository at this point in the history
  • Loading branch information
bboe committed Feb 6, 2025
1 parent e6c6eb4 commit ba4fe31
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 188 deletions.
4 changes: 2 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Unreleased
- Remove ``Redditor.gildings`` method.
- Remove ``Subreddit.mod.inbox``, ``Subreddit.mod.unread``, and
``Subreddit.mod.stream.unread`` methods.
- Remove ``Subreddits.search_by_topic`` method.
- Remove ``Subreddits.gold`` method.
- Remove :class:`.Reddit` keyword argument ``token_manager`` and all associated token
managers.
Expand Down Expand Up @@ -1051,8 +1052,7 @@ as described below:

**Added**

- :meth:`.Subreddits.search_by_topic` to search subreddits by topic. (see:
https://www.reddit.com/dev/api/#GET_api_subreddits_by_topic).
- ``Subreddits.search_by_topic`` to search subreddits by topic.
- :meth:`.LiveHelper.__call__` to provide interface to
``praw.models.LiveThread.__init__``.
- :class:`.SubredditFilters` to work with filters for special subreddits, like
Expand Down
1 change: 0 additions & 1 deletion praw/endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@
"subreddit_filter_list": "api/filter/user/{user}/f/{special}",
"subreddit_settings": "r/{subreddit}/about/edit/",
"subreddit_stylesheet": "r/{subreddit}/api/subreddit_stylesheet/",
"subreddits_by_topic": "api/subreddits_by_topic",
"subreddits_default": "subreddits/default/",
"subreddits_name_search": "api/search_reddit_names/",
"subreddits_new": "subreddits/new/",
Expand Down
13 changes: 0 additions & 13 deletions praw/models/subreddits.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,6 @@ def search_by_name(
)
return [self._reddit.subreddit(x) for x in result["names"]]

def search_by_topic(self, query: str) -> list[praw.models.Subreddit]:
"""Return list of Subreddits whose topics match ``query``.
:param query: Search for subreddits relevant to the search topic.
.. note::
As of 09/01/2020, this endpoint always returns 404.
"""
result = self._reddit.get(API_PATH["subreddits_by_topic"], params={"query": query})
return [self._reddit.subreddit(x["name"]) for x in result if x.get("name")]

def stream(self, **stream_options: str | int | dict[str, str]) -> Iterator[praw.models.Subreddit]:
"""Yield new subreddits as they are created.
Expand Down
162 changes: 0 additions & 162 deletions tests/integration/cassettes/TestSubreddits.test_search_by_topic.json

This file was deleted.

10 changes: 0 additions & 10 deletions tests/integration/models/test_subreddits.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@ def test_search_by_name(self, reddit):
assert len(subreddits) > 1
assert all(isinstance(x, Subreddit) for x in subreddits)

def test_search_by_topic(self, reddit):
subreddits = reddit.subreddits.search_by_topic("python")
assert isinstance(subreddits, list)
assert len(subreddits) > 1
assert all(isinstance(x, Subreddit) for x in subreddits)

subreddits = reddit.subreddits.search_by_topic("xvfx2741r")
assert isinstance(subreddits, list)
assert len(subreddits) == 0

def test_stream(self, reddit):
generator = reddit.subreddits.stream()
for _i in range(101):
Expand Down

0 comments on commit ba4fe31

Please sign in to comment.