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

Commitcb3ad6c

Browse files
chore: add type-hints to gitlab/v4/objects/pipelines.py
1 parent8b6078f commitcb3ad6c

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

‎gitlab/v4/objects/pipelines.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
fromtypingimportAny,cast,Dict,Optional,TYPE_CHECKING,Union
2+
3+
importrequests
4+
15
fromgitlabimportcli
26
fromgitlabimportexceptionsasexc
37
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject
@@ -52,7 +56,7 @@ class ProjectPipeline(RefreshMixin, ObjectDeleteMixin, RESTObject):
5256

5357
@cli.register_custom_action("ProjectPipeline")
5458
@exc.on_http_error(exc.GitlabPipelineCancelError)
55-
defcancel(self,**kwargs):
59+
defcancel(self,**kwargs:Any)->Union[Dict[str,Any],requests.Response]:
5660
"""Cancel the job.
5761
5862
Args:
@@ -67,7 +71,7 @@ def cancel(self, **kwargs):
6771

6872
@cli.register_custom_action("ProjectPipeline")
6973
@exc.on_http_error(exc.GitlabPipelineRetryError)
70-
defretry(self,**kwargs):
74+
defretry(self,**kwargs:Any)->Union[Dict[str,Any],requests.Response]:
7175
"""Retry the job.
7276
7377
Args:
@@ -98,7 +102,14 @@ class ProjectPipelineManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManage
98102
)
99103
_create_attrs=RequiredOptional(required=("ref",))
100104

101-
defcreate(self,data,**kwargs):
105+
defget(
106+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
107+
)->ProjectPipeline:
108+
returncast(ProjectPipeline,super().get(id=id,lazy=lazy,**kwargs))
109+
110+
defcreate(
111+
self,data:Optional[Dict[str,Any]]=None,**kwargs:Any
112+
)->ProjectPipeline:
102113
"""Creates a new object.
103114
104115
Args:
@@ -114,8 +125,12 @@ def create(self, data, **kwargs):
114125
RESTObject: A new instance of the managed object class build with
115126
the data sent by the server
116127
"""
128+
ifTYPE_CHECKING:
129+
assertself.pathisnotNone
117130
path=self.path[:-1]# drop the 's'
118-
returnCreateMixin.create(self,data,path=path,**kwargs)
131+
returncast(
132+
ProjectPipeline,CreateMixin.create(self,data,path=path,**kwargs)
133+
)
119134

120135

121136
classProjectPipelineJob(RESTObject):
@@ -169,7 +184,7 @@ class ProjectPipelineSchedule(SaveMixin, ObjectDeleteMixin, RESTObject):
169184

170185
@cli.register_custom_action("ProjectPipelineSchedule")
171186
@exc.on_http_error(exc.GitlabOwnershipError)
172-
deftake_ownership(self,**kwargs):
187+
deftake_ownership(self,**kwargs:Any)->None:
173188
"""Update the owner of a pipeline schedule.
174189
175190
Args:
@@ -181,11 +196,13 @@ def take_ownership(self, **kwargs):
181196
"""
182197
path=f"{self.manager.path}/{self.get_id()}/take_ownership"
183198
server_data=self.manager.gitlab.http_post(path,**kwargs)
199+
ifTYPE_CHECKING:
200+
assertisinstance(server_data,dict)
184201
self._update_attrs(server_data)
185202

186203
@cli.register_custom_action("ProjectPipelineSchedule")
187204
@exc.on_http_error(exc.GitlabPipelinePlayError)
188-
defplay(self,**kwargs):
205+
defplay(self,**kwargs:Any)->Dict[str,Any]:
189206
"""Trigger a new scheduled pipeline, which runs immediately.
190207
The next scheduled run of this pipeline is not affected.
191208
@@ -198,6 +215,8 @@ def play(self, **kwargs):
198215
"""
199216
path=f"{self.manager.path}/{self.get_id()}/play"
200217
server_data=self.manager.gitlab.http_post(path,**kwargs)
218+
ifTYPE_CHECKING:
219+
assertisinstance(server_data,dict)
201220
self._update_attrs(server_data)
202221
returnserver_data
203222

@@ -213,6 +232,11 @@ class ProjectPipelineScheduleManager(CRUDMixin, RESTManager):
213232
optional=("description","ref","cron","cron_timezone","active"),
214233
)
215234

235+
defget(
236+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
237+
)->ProjectPipelineSchedule:
238+
returncast(ProjectPipelineSchedule,super().get(id=id,lazy=lazy,**kwargs))
239+
216240

217241
classProjectPipelineTestReport(RESTObject):
218242
_id_attr=None

‎pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module = [
1414
"docs.ext.*",
1515
"gitlab.v4.objects.files",
1616
"gitlab.v4.objects.labels",
17-
"gitlab.v4.objects.pipelines",
1817
"gitlab.v4.objects.repositories",
1918
"gitlab.v4.objects.services",
2019
"gitlab.v4.objects.sidekiq",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp