Skip to content

feat: Initial support for httpx #2336

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

Closed
wants to merge 1 commit into from
Closed

Conversation

lmilbaum
Copy link

@lmilbaum lmilbaum commented Oct 20, 2022

A followup of #1036
Two clients defined: requests and httpx. As long as httpx is not fully implemented and adopted by the community, keeping the requests client as the default.

@codecov-commenter
Copy link

codecov-commenter commented Oct 20, 2022

Codecov Report

Merging #2336 (9626499) into main (9d2b1ad) will decrease coverage by 0.81%.
The diff coverage is 84.42%.

@@            Coverage Diff             @@
##             main    #2336      +/-   ##
==========================================
- Coverage   95.96%   95.14%   -0.82%     
==========================================
  Files          80       82       +2     
  Lines        5331     5440     +109     
==========================================
+ Hits         5116     5176      +60     
- Misses        215      264      +49     
Flag Coverage Δ
api_func_v4 83.05% <71.62%> (-0.65%) ⬇️
cli_func_v4 81.72% <64.01%> (-0.64%) ⬇️
unit 87.07% <79.58%> (-0.66%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
gitlab/http_clients/_httpx_client.py 0.00% <0.00%> (ø)
gitlab/mixins.py 92.05% <ø> (ø)
gitlab/v4/objects/deploy_keys.py 96.42% <ø> (ø)
gitlab/v4/objects/groups.py 89.94% <ø> (ø)
gitlab/v4/objects/repositories.py 83.56% <ø> (ø)
gitlab/client.py 95.89% <90.69%> (-2.67%) ⬇️
gitlab/http_clients/_request_sclient.py 96.87% <96.87%> (ø)
gitlab/const.py 100.00% <100.00%> (ø)
gitlab/v4/objects/commits.py 94.87% <100.00%> (ø)
gitlab/v4/objects/environments.py 100.00% <100.00%> (ø)
... and 6 more

@lmilbaum lmilbaum force-pushed the httpx branch 2 times, most recently from 183d29d to 3a363d2 Compare October 20, 2022 10:52
Copy link
Member

@nejch nejch left a comment

Choose a reason for hiding this comment

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

@lmilbaum I made a quick initial pass. Would be interested to see how this runs on functional tests. Thanks a lot for working on this, it's something I've been thinking of myself for a while!

@lmilbaum lmilbaum force-pushed the httpx branch 3 times, most recently from 9db988a to 1a3e23d Compare October 20, 2022 14:36
@lmilbaum lmilbaum requested a review from nejch October 20, 2022 14:36
@lmilbaum lmilbaum force-pushed the httpx branch 18 times, most recently from 20bcffb to 3918639 Compare October 22, 2022 16:39
@lmilbaum lmilbaum marked this pull request as ready for review October 22, 2022 16:57
@lmilbaum lmilbaum force-pushed the httpx branch 2 times, most recently from 1a7938b to fa23370 Compare October 28, 2022 09:16
@lmilbaum lmilbaum requested review from JohnVillalovos and nejch and removed request for nejch and JohnVillalovos November 1, 2022 11:53
@nejch
Copy link
Member

nejch commented Nov 1, 2022

@lmilbaum Thanks for all the work on this!!
I just did a quick review. If you disagree with my comments don't be afraid to say so slightly_smiling_face I am often wrong!
One concern I have is all the adding of Any to a lot of the type-hints.

Yeah. I can understand why. I didn't find any other solution. The understanding that this is an interim step, helps me go for this option.

Thanks both for driving this, sorry again this is taking a while for me to get back into, I thought this would be easier and only the most low-level stuff factored out, similar to how it's done in https://python-redmine.com/advanced/request_engines.html / https://github.com/maxtepkeev/python-redmine/tree/master/redminelib/engines. So just wanted to make sure we take a good look before we merge if there's a simple way :)

@lmilbaum
Copy link
Author

lmilbaum commented Nov 3, 2022

@lmilbaum Thanks for all the work on this!!
I just did a quick review. If you disagree with my comments don't be afraid to say so slightly_smiling_face I am often wrong!
One concern I have is all the adding of Any to a lot of the type-hints.

Yeah. I can understand why. I didn't find any other solution. The understanding that this is an interim step, helps me go for this option.

Thanks both for driving this, sorry again this is taking a while for me to get back into, I thought this would be easier and only the most low-level stuff factored out, similar to how it's done in https://python-redmine.com/advanced/request_engines.html / https://github.com/maxtepkeev/python-redmine/tree/master/redminelib/engines. So just wanted to make sure we take a good look before we merge if there's a simple way :)

I liked the approach taken in python-redmine. The question I have with this approach is wether it goes along with our approach of eventually dropping the request http client/engine and stay with only httpx.

@lmilbaum lmilbaum force-pushed the httpx branch 3 times, most recently from dc66009 to 55edad8 Compare November 7, 2022 03:16
@lmilbaum lmilbaum force-pushed the httpx branch 2 times, most recently from c0132ac to 9626499 Compare November 18, 2022 14:00
@lmilbaum
Copy link
Author

Would breaking this PR into smaller pieces would make sense?

@nejch
Copy link
Member

nejch commented Nov 18, 2022

Would breaking this PR into smaller pieces would make sense?

I think this might help yes @lmilbaum!
It would probably be a smaller PR if we don't take out all the methods as @JohnVillalovos suggested:

https://github.com/python-gitlab/python-gitlab/pull/2336/files#r1010073025
https://github.com/python-gitlab/python-gitlab/pull/2336/files#r1010073368

Also, it would potentially be a smaller PR if we ensure we keep public http_* methods in the main client so that we don't need to change the tests, because this is a public API on the Gitlab instance. We may just have private methods in backend clients that these wrap, but we somehow need to support this for now IMO.

https://python-gitlab.readthedocs.io/en/stable/api-levels.html

@JohnVillalovos
Copy link
Member

So biggest issue with this for me is the type-hints. Everything having Any added. I worked a LONG time adding type-hints to the code and this kind of throws it all away :(

So I think we need to figure out a solution that doesn't use Any.

@lmilbaum
Copy link
Author

Thank you for the feedback @nejch and @JohnVillalovos. I've started breaking this up into smaller PRs. Take a look at #2382

@lmilbaum lmilbaum force-pushed the httpx branch 2 times, most recently from 084c405 to 884daf3 Compare November 24, 2022 01:23
@lmilbaum lmilbaum marked this pull request as draft December 5, 2022 12:26
@lmilbaum lmilbaum closed this Dec 9, 2022
@lmilbaum lmilbaum deleted the httpx branch December 10, 2022 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants