Skip to content

Commit

Permalink
Sort praw.reddit.Reddit.info arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
LilSpazJoekp committed Jan 3, 2022
1 parent 9f04a3f commit 8f94d41
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion praw/models/reddit/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ def subreddit(self) -> "praw.models.Subreddit":
subreddit = collection.subreddit
"""
return next(self._reddit.info([self.subreddit_id]))
return next(self._reddit.info(fullnames=[self.subreddit_id]))

def __init__(
self,
Expand Down
6 changes: 4 additions & 2 deletions praw/reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,13 @@ def get(
"""
return self._objectify_request(method="GET", params=params, path=path)

@_deprecate_args("fullnames", "url", "subreddits")
def info(
self,
*,
fullnames: Optional[Iterable[str]] = None,
url: Optional[str] = None,
subreddits: Optional[Iterable[Union["praw.models.Subreddit", str]]] = None,
url: Optional[str] = None,
) -> Generator[
Union["praw.models.Subreddit", "praw.models.Comment", "praw.models.Submission"],
None,
Expand All @@ -619,9 +621,9 @@ def info(
:param fullnames: A list of fullnames for comments, submissions, and/or
subreddits.
:param url: A url (as a string) to retrieve lists of link submissions from.
:param subreddits: A list of subreddit names or :class:`.Subreddit` objects to
retrieve subreddits from.
:param url: A url (as a string) to retrieve lists of link submissions from.
:returns: A generator that yields found items in their relative order.
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def test_info(self):
for base in bases:
items.append(f"{base}{i:02d}")

item_generator = self.reddit.info(items)
item_generator = self.reddit.info(fullnames=items)
with self.use_cassette():
results = list(item_generator)
assert len(results) > 100
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ def test_context_manager(self):

def test_info__invalid_param(self):
with pytest.raises(TypeError) as excinfo:
self.reddit.info(None)
self.reddit.info(fullnames=None)

err_str = "Either `fullnames`, `url`, or `subreddits` must be provided."
assert str(excinfo.value) == err_str

with pytest.raises(TypeError) as excinfo:
self.reddit.info([], "")
self.reddit.info(fullnames=[], url="")

assert str(excinfo.value) == err_str

Expand All @@ -123,7 +123,7 @@ def test_invalid_config(self):

def test_info__not_list(self):
with pytest.raises(TypeError) as excinfo:
self.reddit.info("Let's try a string")
self.reddit.info(fullnames="Let's try a string")

assert "must be a non-str iterable" in str(excinfo.value)

Expand Down
2 changes: 1 addition & 1 deletion tools/generate_award_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def get_request_params(client_id, redirect_uri, thing):
return

reddit.auth.authorize(params["code"])
thing = list(reddit.info([thing]))[0]
thing = list(reddit.info(fullnames=[thing]))[0]
subreddit = thing.subreddit_id
return reddit._authorized_core._authorizer.access_token, thing.fullname, subreddit

Expand Down

0 comments on commit 8f94d41

Please sign in to comment.