httpx icon indicating copy to clipboard operation
httpx copied to clipboard

Provide request_class, response_class for httpx.Client

Open 93578237 opened this issue 1 year ago • 7 comments

Summary

Closes #717

Checklist

  • [x] I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • [ ] I've updated the documentation accordingly.

93578237 avatar May 11 '24 12:05 93578237

httpx.Reponse.raise_for_status() need to return Self instead of Response, which is added in py311.

So we need typing_extensions.Self in lower version.

or we can use def raise_for_status(self: Type[T]) -> T: instead.

Should also consider add a generic typing for response type and request type of client instance.

trim21 avatar May 21 '24 21:05 trim21

generic type for request and response type

https://github.com/encode/httpx/issues/717#issuecomment-2118083691

93578237 avatar May 22 '24 02:05 93578237

return type of httpx.Reponse.raise_for_status still need to update

trim21 avatar Sep 23 '24 16:09 trim21

Hi! Just wondering what's the status on this? Is there any intention to get it merged?

thomasht86 avatar Jan 27 '25 06:01 thomasht86

Hello, thanks to all involved for the great work! Are there any updates with respect to this PR? It would be very useful atm :sweat_smile:

oelhammouchi avatar Feb 23 '25 13:02 oelhammouchi

any news for this PR?

MarcBresson avatar Aug 14 '25 22:08 MarcBresson

@MarcBresson I'm not progressing this because the work on the httpx 1.0 prerelease deals with this much more comprehensively. (To the point that implementing a custom client class is really simple to implement)

Eg. There's a worked through example on https://www.encode.io/httpnext/clients "Custom client implementations" - contrast that with the existing Client implementation and signatures if you want to start getting a feel for how much sharper and neater the 1.0 typing is.

And, yes... it's taking a little time for me to start presenting the work fully... it's on the way

lovelydinosaur avatar Sep 05 '25 14:09 lovelydinosaur