X Tutup
Skip to content

Commit 5ffa334

Browse files
committed
refactor(asyncio): fix GitlabList
fix typo in v4/objects.py add a async __setup__ to call after init is run
1 parent 9d2ae23 commit 5ffa334

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

gitlab/__init__.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -650,14 +650,18 @@ async def http_list(self, path, query_data=None, as_list=None, **kwargs):
650650
url = self._build_url(path)
651651

652652
if get_all is True and as_list is True:
653-
return list(GitlabList(self, url, query_data, **kwargs))
653+
return list(await GitlabList(self, url, query_data, **kwargs).__setup__())
654654

655655
if "page" in kwargs or as_list is True:
656656
# pagination requested, we return a list
657-
return list(GitlabList(self, url, query_data, get_next=False, **kwargs))
657+
return list(
658+
await GitlabList(
659+
self, url, query_data, get_next=False, **kwargs
660+
).__setup__()
661+
)
658662

659663
# No pagination, generator requested
660-
return GitlabList(self, url, query_data, **kwargs)
664+
return await GitlabList(self, url, query_data, **kwargs).__setup__()
661665

662666
async def http_post(
663667
self, path, query_data=None, post_data=None, files=None, **kwargs
@@ -779,11 +783,16 @@ class GitlabList(object):
779783
the API again when needed.
780784
"""
781785

782-
async def __init__(self, gl, url, query_data, get_next=True, **kwargs):
786+
def __init__(self, gl, url, query_data, get_next=True, **kwargs):
783787
self._gl = gl
784-
await self._query(url, query_data, **kwargs)
788+
self.url = url
789+
self.query_data = query_data
790+
self.kwargs = kwargs
785791
self._get_next = get_next
786792

793+
async def __setup__(self):
794+
await self._query(self.url, self.query_data, **self.kwargs)
795+
787796
async def _query(self, url, query_data=None, **kwargs):
788797
query_data = query_data or {}
789798
result = await self._gl.http_request(

gitlab/v4/objects.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
from gitlab.base import * # noqa
2424
from gitlab import cli
25-
from gitlab.exceptions import exc # noqa
25+
from gitlab.exceptions import * # noqa
2626
from gitlab.mixins import * # noqa
2727
from gitlab import types
2828
from gitlab import utils
@@ -3701,7 +3701,7 @@ async def async_raw(
37013701
def raw(
37023702
self, file_path, ref, streamed=False, action=None, chunk_size=1024, **kwargs
37033703
):
3704-
loop = async.get_event_loop()
3704+
loop = asyncio.get_event_loop()
37053705
return loop.run_until_complete(
37063706
self.async_raw(
37073707
file_path, ref, streamed=False, action=None, chunck_size=1024, **kwargs

0 commit comments

Comments
 (0)
X Tutup