Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAsync and sync compatible wrapper #1036
Conversation
Make all functions async Use httpx instead of httpx Make decorators async to correctly wrap async methods
Change _http_auth on direct httpx.AsyncClient.auth property
Fix some errors that are met on the way to async
This possibly is temporary solution because httpx raises TypeError when tries to init DataField with bool value
feat: httpx based python-gitlab
on_http_error should work with sync functions that return coroutines and handle errors when coroutines will be awaited
Also provide async and sync interface to interact with GitlabList
Provide base of gitlab client along with implementations of sync and async interface
Basic principle is that we won't use constructor to create object, instead classmethod would be used that return either object or corotine that returns object
From now on v4 object method would return coroutine or desired data
Implement decorator that deals with possible awaitable object and run function that is passed as callback and return awaitable or data Decorate all edge cases with postprocessing in v4 objects with awaitable_postprocess
Since _update_attrs is some sort of postprocess then we decorated it so Hence changed interface we now can explicitly user self._update_attrs but be sure that we return it, since it's awaitable
feat(async): async and sync compatible wrapper
chore: provide docstrings for gitlab client implementations
|
Here is some sort of notable changes:
|
I just noticed something:
That's really cool :) |
|
@vishes-shell Thanks for all the work that you're doing! People could have been using chunk_size, by providing a different But we have nothing about this officially in the docs, so I would say we can solve this by mentioning it in the release notes. We anyway need to bump the version to 3.X. |
|
@max-wittig I tried earlier and at least in some cases it can even be just: project = gl.projects.get(1)
export = project.exports.create({})
dl = export.download(chunk_size=512)From what I see in the current solution by @vishes-shell this would still work and wouldn't break anything, the argument would just be ignored by |
I've rebuild wrapper to support async and sync interface with support of
httpx.There is two gitlab clients:
GitlabandAsyncGitlab, initerfaces are the same, except most of the methods would return awaitable object in AsyncGitlab.Related #1025