-
-
Notifications
You must be signed in to change notification settings - Fork 839
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make the response's request parameter optional #1238
Conversation
Okay, so it turns out this issue is actually more awkawrd than realised at first, because although we do want Here's what I think we're going to need to do here...
That'll allow us to have...
You're welcome to take on these follow ups yourself, or else I'd also be happy to take a look at them. |
Thanks for the detailed guidance. |
httpx/_models.py
Outdated
if self._request is None: | ||
raise ValueError(message) | ||
raise HTTPStatusError(message, request=self._request, response=self) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Raising a ValueError inside raise_for_status seems a bit off ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest we start the method with something like...
if self._request is None:
raise RuntimeError("Cannot call `raise_for_status` as the request instance has not been set on this response.")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, yup! Thanks so much for your time on this!
I've added in a _wrap_decode_errors
context manager, to remove some of the replication, and get the test coverage back up to 100%
Make the response's request parameter optional
Part of #1227