fix(reddit): remove unreachable 429 check after raise_for_status() - #15177
Merged
cclauss merged 4 commits intoSep 4, 2026
Merged
Conversation
11 tasks
Member
|
We no longer need data = httpx.get(
f"https://www.reddit.com/r/{subreddit}/{age}.json?limit={limit}",
headers={"User-agent": "A random string"},
timeout=10,
).raise_for_status().json() |
cclauss
reviewed
Sep 4, 2026
Member
There was a problem hiding this comment.
Suggested change
| subreddit: str, limit: int = 1, age: Literal["new", "top", "hot"] = "new", wanted_data: list | None = None |
Contributor
Author
|
Love it — that fluent chain reads much better and drops the now-unused data = (
httpx.get(
f"https://www.reddit.com/r/{subreddit}/{age}.json?limit={limit}",
headers={"User-agent": "A random string"},
timeout=10,
)
.raise_for_status()
.json()
)Kept the short comment noting 429 is already covered by |
Updated the age parameter to use Literal for specific values.
for more information, see https://pre-commit.ci
cclauss
enabled auto-merge (squash)
September 4, 2026 06:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the genuine bug @cclauss flagged in #15174 (
web_programming/reddit.py).Two problems with the removed lines:
response.raise_for_status()already raiseshttpx.HTTPStatusErrorfor every 4xx/5xx response, including 429, so the followingif response.status_code == 429can never be true — execution never reaches it.httpx.HTTPError.__init__(self, message)takes a message string and has noresponseparameter, sohttpx.HTTPError(response=response)would raiseTypeErrorif it ever ran. (This is exactly theunknown-argument/missing-argumentdiagnostictyreports on this file.)The fix keeps
raise_for_status()— the intended rate-limit behaviour is preserved — and drops the dead branch, with a short comment explaining why no extra status check is needed. The__main__note about Error 429 still applies.Checklist: