Keep HTTPError as a base class for .request() and .raise_for_status() #1125
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.
Closes #1108, and following rationale in #1083 (comment), which I'll repeat here...
I think there's probably also a decent case to make for not deprecating it at all, and instead keeping it as a base class, but only for
RequestError
andHTTPStatusError
, so that...Which means existing code all keeps working as expected, while still providing finer-grained classes where needed.
It's also more concise than the alternative...
This hadn't really occurred to me when looking at #1095.
The typing is also still nice and clear here. Both
HTTPStatusError
andRequestError
provide.request
, so we can suitably annotate that on the base class. However accessing.response
onhttpx.HTTPError
would be a typing error, since it could either be aRequestError
(which isn't associated with a response) or aHTTPStatusError
(which is).The following are all valid...
I think this is probably all a usability win for our users given...
except httpx.HTTPError as exc:
is more concise thanexcept (httpx.RequestError, httpx.StatusCodeError) as exc:
How do we feel about this?