| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 13243b7 commit 93e39a2
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,5 @@ | |||
| 1 | + from typing import Any, cast, Dict, Tuple, TYPE_CHECKING, Union | ||
| 2 | + | ||
| 1 | 3 | from gitlab import cli | |
| 2 | 4 | from gitlab import exceptions as exc | |
| 3 | 5 | from gitlab import types | |
@@ -65,6 +67,9 @@ class IssueManager(RetrieveMixin, RESTManager): | |||
| 65 | 67 | ) | |
| 66 | 68 | _types = {"iids": types.ListAttribute, "labels": types.ListAttribute} | |
| 67 | 69 | ||
| 70 | + def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Issue: | ||
| 71 | + return cast(Issue, super().get(id=id, lazy=lazy, **kwargs)) | ||
| 72 | + | ||
| 68 | 73 | ||
| 69 | 74 | class GroupIssue(RESTObject): | |
| 70 | 75 | pass | |
@@ -116,7 +121,7 @@ class ProjectIssue( | |||
| 116 | 121 | ||
| 117 | 122 | @cli.register_custom_action("ProjectIssue", ("to_project_id",)) | |
| 118 | 123 | @exc.on_http_error(exc.GitlabUpdateError) | |
| 119 | - def move(self, to_project_id, **kwargs): | ||
| 124 | + def move(self, to_project_id: int, **kwargs: Any) -> None: | ||
| 120 | 125 | """Move the issue to another project. | |
| 121 | 126 | ||
| 122 | 127 | Args: | |
@@ -130,11 +135,13 @@ def move(self, to_project_id, **kwargs): | |||
| 130 | 135 | path = f"{self.manager.path}/{self.get_id()}/move" | |
| 131 | 136 | data = {"to_project_id": to_project_id} | |
| 132 | 137 | server_data = self.manager.gitlab.http_post(path, post_data=data, **kwargs) | |
| 138 | + if TYPE_CHECKING: | ||
| 139 | + assert isinstance(server_data, dict) | ||
| 133 | 140 | self._update_attrs(server_data) | |
| 134 | 141 | ||
| 135 | 142 | @cli.register_custom_action("ProjectIssue") | |
| 136 | 143 | @exc.on_http_error(exc.GitlabGetError) | |
| 137 | - def related_merge_requests(self, **kwargs): | ||
| 144 | + def related_merge_requests(self, **kwargs: Any) -> Dict[str, Any]: | ||
| 138 | 145 | """List merge requests related to the issue. | |
| 139 | 146 | ||
| 140 | 147 | Args: | |
@@ -148,11 +155,14 @@ def related_merge_requests(self, **kwargs): | |||
| 148 | 155 | list: The list of merge requests. | |
| 149 | 156 | """ | |
| 150 | 157 | path = f"{self.manager.path}/{self.get_id()}/related_merge_requests" | |
| 151 | - return self.manager.gitlab.http_get(path, **kwargs) | ||
| 158 | + result = self.manager.gitlab.http_get(path, **kwargs) | ||
| 159 | + if TYPE_CHECKING: | ||
| 160 | + assert isinstance(result, dict) | ||
| 161 | + return result | ||
| 152 | 162 | ||
| 153 | 163 | @cli.register_custom_action("ProjectIssue") | |
| 154 | 164 | @exc.on_http_error(exc.GitlabGetError) | |
| 155 | - def closed_by(self, **kwargs): | ||
| 165 | + def closed_by(self, **kwargs: Any) -> Dict[str, Any]: | ||
| 156 | 166 | """List merge requests that will close the issue when merged. | |
| 157 | 167 | ||
| 158 | 168 | Args: | |
@@ -166,7 +176,10 @@ def closed_by(self, **kwargs): | |||
| 166 | 176 | list: The list of merge requests. | |
| 167 | 177 | """ | |
| 168 | 178 | path = f"{self.manager.path}/{self.get_id()}/closed_by" | |
| 169 | - return self.manager.gitlab.http_get(path, **kwargs) | ||
| 179 | + result = self.manager.gitlab.http_get(path, **kwargs) | ||
| 180 | + if TYPE_CHECKING: | ||
| 181 | + assert isinstance(result, dict) | ||
| 182 | + return result | ||
| 170 | 183 | ||
| 171 | 184 | ||
| 172 | 185 | class ProjectIssueManager(CRUDMixin, RESTManager): | |
@@ -222,6 +235,11 @@ class ProjectIssueManager(CRUDMixin, RESTManager): | |||
| 222 | 235 | ) | |
| 223 | 236 | _types = {"iids": types.ListAttribute, "labels": types.ListAttribute} | |
| 224 | 237 | ||
| 238 | + def get( | ||
| 239 | + self, id: Union[str, int], lazy: bool = False, **kwargs: Any | ||
| 240 | + ) -> ProjectIssue: | ||
| 241 | + return cast(ProjectIssue, super().get(id=id, lazy=lazy, **kwargs)) | ||
| 242 | + | ||
| 225 | 243 | ||
| 226 | 244 | class ProjectIssueLink(ObjectDeleteMixin, RESTObject): | |
| 227 | 245 | _id_attr = "issue_link_id" | |
@@ -234,7 +252,11 @@ class ProjectIssueLinkManager(ListMixin, CreateMixin, DeleteMixin, RESTManager): | |||
| 234 | 252 | _create_attrs = RequiredOptional(required=("target_project_id", "target_issue_iid")) | |
| 235 | 253 | ||
| 236 | 254 | @exc.on_http_error(exc.GitlabCreateError) | |
| 237 | - def create(self, data, **kwargs): | ||
| 255 | + # NOTE(jlvillal): Signature doesn't match CreateMixin.create() so ignore | ||
| 256 | + # type error | ||
| 257 | + def create( # type: ignore | ||
| 258 | + self, data: Dict[str, Any], **kwargs: Any | ||
| 259 | + ) -> Tuple[RESTObject, RESTObject]: | ||
| 238 | 260 | """Create a new object. | |
| 239 | 261 | ||
| 240 | 262 | Args: | |
@@ -250,7 +272,12 @@ def create(self, data, **kwargs): | |||
| 250 | 272 | GitlabCreateError: If the server cannot perform the request | |
| 251 | 273 | """ | |
| 252 | 274 | self._check_missing_create_attrs(data) | |
| 275 | + if TYPE_CHECKING: | ||
| 276 | + assert self.path is not None | ||
| 253 | 277 | server_data = self.gitlab.http_post(self.path, post_data=data, **kwargs) | |
| 278 | + if TYPE_CHECKING: | ||
| 279 | + assert isinstance(server_data, dict) | ||
| 280 | + assert self._parent is not None | ||
| 254 | 281 | source_issue = ProjectIssue(self._parent.manager, server_data["source_issue"]) | |
| 255 | 282 | target_issue = ProjectIssue(self._parent.manager, server_data["target_issue"]) | |
| 256 | 283 | return source_issue, target_issue | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -13,7 +13,6 @@ module = [ | |||
| 13 | 13 | "docs.*", | |
| 14 | 14 | "docs.ext.*", | |
| 15 | 15 | "gitlab.v4.objects.files", | |
| 16 | - "gitlab.v4.objects.issues", | ||
| 17 | 16 | "gitlab.v4.objects.jobs", | |
| 18 | 17 | "gitlab.v4.objects.labels", | |
| 19 | 18 | "gitlab.v4.objects.milestones", | |
| Back | FazBrowse Home | New Git URL |
0 commit comments