Skip to content
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

Provide request_class, response_class for httpx.Client #3199

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

q0w
Copy link

@q0w q0w commented May 11, 2024

Summary

Closes #717

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • 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.

@q0w q0w marked this pull request as draft May 11, 2024 12:25
@q0w q0w marked this pull request as ready for review May 11, 2024 12:40
Copy link
Contributor

@T-256 T-256 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets have it ✌️

@@ -164,6 +164,7 @@ class BaseClient:
def __init__(
self,
*,
request_class: type[Request] | None = None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably also response_class, right?
Also I guess move this to the end of the parameters.

Copy link
Author

@q0w q0w May 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Presumably also response_class, right?

I thought about that, but baseclient has no logic related with responses, so response_class is now added only in Client for passing to transports. I can add response_class, if needed.

@trim21
Copy link
Contributor

trim21 commented May 21, 2024

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.

@q0w
Copy link
Author

q0w commented May 22, 2024

generic type for request and response type

#717 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom JSON library
4 participants