| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 8b6078f commit cb3ad6c
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,7 @@ | |||
| 1 | + from typing import Any, cast, Dict, Optional, TYPE_CHECKING, Union | ||
| 2 | + | ||
| 3 | + import requests | ||
| 4 | + | ||
| 1 | 5 | from gitlab import cli | |
| 2 | 6 | from gitlab import exceptions as exc | |
| 3 | 7 | from gitlab.base import RequiredOptional, RESTManager, RESTObject | |
@@ -52,7 +56,7 @@ class ProjectPipeline(RefreshMixin, ObjectDeleteMixin, RESTObject): | |||
| 52 | 56 | ||
| 53 | 57 | @cli.register_custom_action("ProjectPipeline") | |
| 54 | 58 | @exc.on_http_error(exc.GitlabPipelineCancelError) | |
| 55 | - def cancel(self, **kwargs): | ||
| 59 | + def cancel(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: | ||
| 56 | 60 | """Cancel the job. | |
| 57 | 61 | ||
| 58 | 62 | Args: | |
@@ -67,7 +71,7 @@ def cancel(self, **kwargs): | |||
| 67 | 71 | ||
| 68 | 72 | @cli.register_custom_action("ProjectPipeline") | |
| 69 | 73 | @exc.on_http_error(exc.GitlabPipelineRetryError) | |
| 70 | - def retry(self, **kwargs): | ||
| 74 | + def retry(self, **kwargs: Any) -> Union[Dict[str, Any], requests.Response]: | ||
| 71 | 75 | """Retry the job. | |
| 72 | 76 | ||
| 73 | 77 | Args: | |
@@ -98,7 +102,14 @@ class ProjectPipelineManager(RetrieveMixin, CreateMixin, DeleteMixin, RESTManage | |||
| 98 | 102 | ) | |
| 99 | 103 | _create_attrs = RequiredOptional(required=("ref",)) | |
| 100 | 104 | ||
| 101 | - def create(self, data, **kwargs): | ||
| 105 | + def get( | ||
| 106 | + self, id: Union[str, int], lazy: bool = False, **kwargs: Any | ||
| 107 | + ) -> ProjectPipeline: | ||
| 108 | + return cast(ProjectPipeline, super().get(id=id, lazy=lazy, **kwargs)) | ||
| 109 | + | ||
| 110 | + def create( | ||
| 111 | + self, data: Optional[Dict[str, Any]] = None, **kwargs: Any | ||
| 112 | + ) -> ProjectPipeline: | ||
| 102 | 113 | """Creates a new object. | |
| 103 | 114 | ||
| 104 | 115 | Args: | |
@@ -114,8 +125,12 @@ def create(self, data, **kwargs): | |||
| 114 | 125 | RESTObject: A new instance of the managed object class build with | |
| 115 | 126 | the data sent by the server | |
| 116 | 127 | """ | |
| 128 | + if TYPE_CHECKING: | ||
| 129 | + assert self.path is not None | ||
| 117 | 130 | path = self.path[:-1] # drop the 's' | |
| 118 | - return CreateMixin.create(self, data, path=path, **kwargs) | ||
| 131 | + return cast( | ||
| 132 | + ProjectPipeline, CreateMixin.create(self, data, path=path, **kwargs) | ||
| 133 | + ) | ||
| 119 | 134 | ||
| 120 | 135 | ||
| 121 | 136 | class ProjectPipelineJob(RESTObject): | |
@@ -169,7 +184,7 @@ class ProjectPipelineSchedule(SaveMixin, ObjectDeleteMixin, RESTObject): | |||
| 169 | 184 | ||
| 170 | 185 | @cli.register_custom_action("ProjectPipelineSchedule") | |
| 171 | 186 | @exc.on_http_error(exc.GitlabOwnershipError) | |
| 172 | - def take_ownership(self, **kwargs): | ||
| 187 | + def take_ownership(self, **kwargs: Any) -> None: | ||
| 173 | 188 | """Update the owner of a pipeline schedule. | |
| 174 | 189 | ||
| 175 | 190 | Args: | |
@@ -181,11 +196,13 @@ def take_ownership(self, **kwargs): | |||
| 181 | 196 | """ | |
| 182 | 197 | path = f"{self.manager.path}/{self.get_id()}/take_ownership" | |
| 183 | 198 | server_data = self.manager.gitlab.http_post(path, **kwargs) | |
| 199 | + if TYPE_CHECKING: | ||
| 200 | + assert isinstance(server_data, dict) | ||
| 184 | 201 | self._update_attrs(server_data) | |
| 185 | 202 | ||
| 186 | 203 | @cli.register_custom_action("ProjectPipelineSchedule") | |
| 187 | 204 | @exc.on_http_error(exc.GitlabPipelinePlayError) | |
| 188 | - def play(self, **kwargs): | ||
| 205 | + def play(self, **kwargs: Any) -> Dict[str, Any]: | ||
| 189 | 206 | """Trigger a new scheduled pipeline, which runs immediately. | |
| 190 | 207 | The next scheduled run of this pipeline is not affected. | |
| 191 | 208 | ||
@@ -198,6 +215,8 @@ def play(self, **kwargs): | |||
| 198 | 215 | """ | |
| 199 | 216 | path = f"{self.manager.path}/{self.get_id()}/play" | |
| 200 | 217 | server_data = self.manager.gitlab.http_post(path, **kwargs) | |
| 218 | + if TYPE_CHECKING: | ||
| 219 | + assert isinstance(server_data, dict) | ||
| 201 | 220 | self._update_attrs(server_data) | |
| 202 | 221 | return server_data | |
| 203 | 222 | ||
@@ -213,6 +232,11 @@ class ProjectPipelineScheduleManager(CRUDMixin, RESTManager): | |||
| 213 | 232 | optional=("description", "ref", "cron", "cron_timezone", "active"), | |
| 214 | 233 | ) | |
| 215 | 234 | ||
| 235 | + def get( | ||
| 236 | + self, id: Union[str, int], lazy: bool = False, **kwargs: Any | ||
| 237 | + ) -> ProjectPipelineSchedule: | ||
| 238 | + return cast(ProjectPipelineSchedule, super().get(id=id, lazy=lazy, **kwargs)) | ||
| 239 | + | ||
| 216 | 240 | ||
| 217 | 241 | class ProjectPipelineTestReport(RESTObject): | |
| 218 | 242 | _id_attr = None | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,7 +14,6 @@ module = [ | |||
| 14 | 14 | "docs.ext.*", | |
| 15 | 15 | "gitlab.v4.objects.files", | |
| 16 | 16 | "gitlab.v4.objects.labels", | |
| 17 | - "gitlab.v4.objects.pipelines", | ||
| 18 | 17 | "gitlab.v4.objects.repositories", | |
| 19 | 18 | "gitlab.v4.objects.services", | |
| 20 | 19 | "gitlab.v4.objects.sidekiq", | |
| Back | FazBrowse Home | New Git URL |
0 commit comments