Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit212ddfc

Browse files
refactor: avoid possible breaking change in iterator (#2107)
Commitb644721 inadvertentlyintroduced a possible breaking change as it added a new argument`iterator` and added it in between existing (potentially positional) arguments.This moves the `iterator` argument to the end of the argument list andrequires it to be a keyword-only argument.
1 parentebd5795 commit212ddfc

File tree

10 files changed

+66
-28
lines changed

10 files changed

+66
-28
lines changed

‎gitlab/mixins.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,9 +613,10 @@ class DownloadMixin(_RestObjectBase):
613613
defdownload(
614614
self,
615615
streamed:bool=False,
616-
iterator:bool=False,
617616
action:Optional[Callable]=None,
618617
chunk_size:int=1024,
618+
*,
619+
iterator:bool=False,
619620
**kwargs:Any,
620621
)->Optional[Union[bytes,Iterator[Any]]]:
621622
"""Download the archive of a resource export.
@@ -644,7 +645,9 @@ def download(
644645
)
645646
ifTYPE_CHECKING:
646647
assertisinstance(result,requests.Response)
647-
returnutils.response_content(result,streamed,iterator,action,chunk_size)
648+
returnutils.response_content(
649+
result,streamed,action,chunk_size,iterator=iterator
650+
)
648651

649652

650653
classSubscribableMixin(_RestObjectBase):

‎gitlab/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@ def __call__(self, chunk: Any) -> None:
3434
defresponse_content(
3535
response:requests.Response,
3636
streamed:bool,
37-
iterator:bool,
3837
action:Optional[Callable],
3938
chunk_size:int,
39+
*,
40+
iterator:bool,
4041
)->Optional[Union[bytes,Iterator[Any]]]:
4142
ifiterator:
4243
returnresponse.iter_content(chunk_size=chunk_size)

‎gitlab/v4/objects/artifacts.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,10 @@ def download(
7575
ref_name:str,
7676
job:str,
7777
streamed:bool=False,
78-
iterator:bool=False,
7978
action:Optional[Callable]=None,
8079
chunk_size:int=1024,
80+
*,
81+
iterator:bool=False,
8182
**kwargs:Any,
8283
)->Optional[Union[bytes,Iterator[Any]]]:
8384
"""Get the job artifacts archive from a specific tag or branch.
@@ -110,7 +111,9 @@ def download(
110111
)
111112
ifTYPE_CHECKING:
112113
assertisinstance(result,requests.Response)
113-
returnutils.response_content(result,streamed,iterator,action,chunk_size)
114+
returnutils.response_content(
115+
result,streamed,action,chunk_size,iterator=iterator
116+
)
114117

115118
@cli.register_custom_action(
116119
"ProjectArtifactManager", ("ref_name","artifact_path","job")
@@ -122,9 +125,10 @@ def raw(
122125
artifact_path:str,
123126
job:str,
124127
streamed:bool=False,
125-
iterator:bool=False,
126128
action:Optional[Callable]=None,
127129
chunk_size:int=1024,
130+
*,
131+
iterator:bool=False,
128132
**kwargs:Any,
129133
)->Optional[Union[bytes,Iterator[Any]]]:
130134
"""Download a single artifact file from a specific tag or branch from
@@ -158,4 +162,6 @@ def raw(
158162
)
159163
ifTYPE_CHECKING:
160164
assertisinstance(result,requests.Response)
161-
returnutils.response_content(result,streamed,iterator,action,chunk_size)
165+
returnutils.response_content(
166+
result,streamed,action,chunk_size,iterator=iterator
167+
)

‎gitlab/v4/objects/files.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,10 @@ def raw(
230230
file_path:str,
231231
ref:str,
232232
streamed:bool=False,
233-
iterator:bool=False,
234233
action:Optional[Callable[...,Any]]=None,
235234
chunk_size:int=1024,
235+
*,
236+
iterator:bool=False,
236237
**kwargs:Any,
237238
)->Optional[Union[bytes,Iterator[Any]]]:
238239
"""Return the content of a file for a commit.
@@ -265,7 +266,9 @@ def raw(
265266
)
266267
ifTYPE_CHECKING:
267268
assertisinstance(result,requests.Response)
268-
returnutils.response_content(result,streamed,iterator,action,chunk_size)
269+
returnutils.response_content(
270+
result,streamed,action,chunk_size,iterator=iterator
271+
)
269272

270273
@cli.register_custom_action("ProjectFileManager", ("file_path","ref"))
271274
@exc.on_http_error(exc.GitlabListError)

‎gitlab/v4/objects/jobs.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,10 @@ def delete_artifacts(self, **kwargs: Any) -> None:
116116
defartifacts(
117117
self,
118118
streamed:bool=False,
119-
iterator:bool=False,
120119
action:Optional[Callable[...,Any]]=None,
121120
chunk_size:int=1024,
121+
*,
122+
iterator:bool=False,
122123
**kwargs:Any,
123124
)->Optional[Union[bytes,Iterator[Any]]]:
124125
"""Get the job artifacts.
@@ -147,17 +148,20 @@ def artifacts(
147148
)
148149
ifTYPE_CHECKING:
149150
assertisinstance(result,requests.Response)
150-
returnutils.response_content(result,streamed,iterator,action,chunk_size)
151+
returnutils.response_content(
152+
result,streamed,action,chunk_size,iterator=iterator
153+
)
151154

152155
@cli.register_custom_action("ProjectJob")
153156
@exc.on_http_error(exc.GitlabGetError)
154157
defartifact(
155158
self,
156159
path:str,
157160
streamed:bool=False,
158-
iterator:bool=False,
159161
action:Optional[Callable[...,Any]]=None,
160162
chunk_size:int=1024,
163+
*,
164+
iterator:bool=False,
161165
**kwargs:Any,
162166
)->Optional[Union[bytes,Iterator[Any]]]:
163167
"""Get a single artifact file from within the job's artifacts archive.
@@ -187,16 +191,19 @@ def artifact(
187191
)
188192
ifTYPE_CHECKING:
189193
assertisinstance(result,requests.Response)
190-
returnutils.response_content(result,streamed,iterator,action,chunk_size)
194+
returnutils.response_content(
195+
result,streamed,action,chunk_size,iterator=iterator
196+
)
191197

192198
@cli.register_custom_action("ProjectJob")
193199
@exc.on_http_error(exc.GitlabGetError)
194200
deftrace(
195201
self,
196202
streamed:bool=False,
197-
iterator:bool=False,
198203
action:Optional[Callable[...,Any]]=None,
199204
chunk_size:int=1024,
205+
*,
206+
iterator:bool=False,
200207
**kwargs:Any,
201208
)->Dict[str,Any]:
202209
"""Get the job trace.
@@ -226,7 +233,7 @@ def trace(
226233
ifTYPE_CHECKING:
227234
assertisinstance(result,requests.Response)
228235
return_value=utils.response_content(
229-
result,streamed,iterator,action,chunk_size
236+
result,streamed,action,chunk_size,iterator=iterator
230237
)
231238
ifTYPE_CHECKING:
232239
assertisinstance(return_value,dict)

‎gitlab/v4/objects/packages.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ def download(
103103
package_version:str,
104104
file_name:str,
105105
streamed:bool=False,
106-
iterator:bool=False,
107106
action:Optional[Callable]=None,
108107
chunk_size:int=1024,
108+
*,
109+
iterator:bool=False,
109110
**kwargs:Any,
110111
)->Optional[Union[bytes,Iterator[Any]]]:
111112
"""Download a generic package.
@@ -135,7 +136,9 @@ def download(
135136
result=self.gitlab.http_get(path,streamed=streamed,raw=True,**kwargs)
136137
ifTYPE_CHECKING:
137138
assertisinstance(result,requests.Response)
138-
returnutils.response_content(result,streamed,iterator,action,chunk_size)
139+
returnutils.response_content(
140+
result,streamed,action,chunk_size,iterator=iterator
141+
)
139142

140143

141144
classGroupPackage(RESTObject):

‎gitlab/v4/objects/projects.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,10 @@ def snapshot(
476476
self,
477477
wiki:bool=False,
478478
streamed:bool=False,
479-
iterator:bool=False,
480479
action:Optional[Callable]=None,
481480
chunk_size:int=1024,
481+
*,
482+
iterator:bool=False,
482483
**kwargs:Any,
483484
)->Optional[Union[bytes,Iterator[Any]]]:
484485
"""Return a snapshot of the repository.
@@ -508,7 +509,9 @@ def snapshot(
508509
)
509510
ifTYPE_CHECKING:
510511
assertisinstance(result,requests.Response)
511-
returnutils.response_content(result,streamed,iterator,action,chunk_size)
512+
returnutils.response_content(
513+
result,streamed,action,chunk_size,iterator=iterator
514+
)
512515

513516
@cli.register_custom_action("Project", ("scope","search"))
514517
@exc.on_http_error(exc.GitlabSearchError)

‎gitlab/v4/objects/repositories.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,10 @@ def repository_raw_blob(
107107
self,
108108
sha:str,
109109
streamed:bool=False,
110-
iterator:bool=False,
111110
action:Optional[Callable[...,Any]]=None,
112111
chunk_size:int=1024,
112+
*,
113+
iterator:bool=False,
113114
**kwargs:Any,
114115
)->Optional[Union[bytes,Iterator[Any]]]:
115116
"""Return the raw file contents for a blob.
@@ -139,7 +140,9 @@ def repository_raw_blob(
139140
)
140141
ifTYPE_CHECKING:
141142
assertisinstance(result,requests.Response)
142-
returnutils.response_content(result,streamed,iterator,action,chunk_size)
143+
returnutils.response_content(
144+
result,streamed,action,chunk_size,iterator=iterator
145+
)
143146

144147
@cli.register_custom_action("Project", ("from_","to"))
145148
@exc.on_http_error(exc.GitlabGetError)
@@ -195,10 +198,11 @@ def repository_archive(
195198
self,
196199
sha:str=None,
197200
streamed:bool=False,
198-
iterator:bool=False,
199201
action:Optional[Callable[...,Any]]=None,
200202
chunk_size:int=1024,
201203
format:Optional[str]=None,
204+
*,
205+
iterator:bool=False,
202206
**kwargs:Any,
203207
)->Optional[Union[bytes,Iterator[Any]]]:
204208
"""Return an archive of the repository.
@@ -234,7 +238,9 @@ def repository_archive(
234238
)
235239
ifTYPE_CHECKING:
236240
assertisinstance(result,requests.Response)
237-
returnutils.response_content(result,streamed,iterator,action,chunk_size)
241+
returnutils.response_content(
242+
result,streamed,action,chunk_size,iterator=iterator
243+
)
238244

239245
@cli.register_custom_action("Project")
240246
@exc.on_http_error(exc.GitlabDeleteError)

‎gitlab/v4/objects/snippets.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ class Snippet(UserAgentDetailMixin, SaveMixin, ObjectDeleteMixin, RESTObject):
2929
defcontent(
3030
self,
3131
streamed:bool=False,
32-
iterator:bool=False,
3332
action:Optional[Callable[...,Any]]=None,
3433
chunk_size:int=1024,
34+
*,
35+
iterator:bool=False,
3536
**kwargs:Any,
3637
)->Optional[Union[bytes,Iterator[Any]]]:
3738
"""Return the content of a snippet.
@@ -60,7 +61,9 @@ def content(
6061
)
6162
ifTYPE_CHECKING:
6263
assertisinstance(result,requests.Response)
63-
returnutils.response_content(result,streamed,iterator,action,chunk_size)
64+
returnutils.response_content(
65+
result,streamed,action,chunk_size,iterator=iterator
66+
)
6467

6568

6669
classSnippetManager(CRUDMixin,RESTManager):
@@ -106,9 +109,10 @@ class ProjectSnippet(UserAgentDetailMixin, SaveMixin, ObjectDeleteMixin, RESTObj
106109
defcontent(
107110
self,
108111
streamed:bool=False,
109-
iterator:bool=False,
110112
action:Optional[Callable[...,Any]]=None,
111113
chunk_size:int=1024,
114+
*,
115+
iterator:bool=False,
112116
**kwargs:Any,
113117
)->Optional[Union[bytes,Iterator[Any]]]:
114118
"""Return the content of a snippet.
@@ -137,7 +141,9 @@ def content(
137141
)
138142
ifTYPE_CHECKING:
139143
assertisinstance(result,requests.Response)
140-
returnutils.response_content(result,streamed,iterator,action,chunk_size)
144+
returnutils.response_content(
145+
result,streamed,action,chunk_size,iterator=iterator
146+
)
141147

142148

143149
classProjectSnippetManager(CRUDMixin,RESTManager):

‎tests/unit/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_response_content(capsys):
3737

3838
resp=requests.get("https://example.com",stream=True)
3939
utils.response_content(
40-
resp,streamed=True,iterator=False,action=None,chunk_size=1024
40+
resp,streamed=True,action=None,chunk_size=1024,iterator=False
4141
)
4242

4343
captured=capsys.readouterr()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp