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

Commit93e39a2

Browse files
chore: add type-hints to gitlab/v4/objects/issues.py
1 parent13243b7 commit93e39a2

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

‎gitlab/v4/objects/issues.py

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromtypingimportAny,cast,Dict,Tuple,TYPE_CHECKING,Union
2+
13
fromgitlabimportcli
24
fromgitlabimportexceptionsasexc
35
fromgitlabimporttypes
@@ -65,6 +67,9 @@ class IssueManager(RetrieveMixin, RESTManager):
6567
)
6668
_types= {"iids":types.ListAttribute,"labels":types.ListAttribute}
6769

70+
defget(self,id:Union[str,int],lazy:bool=False,**kwargs:Any)->Issue:
71+
returncast(Issue,super().get(id=id,lazy=lazy,**kwargs))
72+
6873

6974
classGroupIssue(RESTObject):
7075
pass
@@ -116,7 +121,7 @@ class ProjectIssue(
116121

117122
@cli.register_custom_action("ProjectIssue", ("to_project_id",))
118123
@exc.on_http_error(exc.GitlabUpdateError)
119-
defmove(self,to_project_id,**kwargs):
124+
defmove(self,to_project_id:int,**kwargs:Any)->None:
120125
"""Move the issue to another project.
121126
122127
Args:
@@ -130,11 +135,13 @@ def move(self, to_project_id, **kwargs):
130135
path=f"{self.manager.path}/{self.get_id()}/move"
131136
data= {"to_project_id":to_project_id}
132137
server_data=self.manager.gitlab.http_post(path,post_data=data,**kwargs)
138+
ifTYPE_CHECKING:
139+
assertisinstance(server_data,dict)
133140
self._update_attrs(server_data)
134141

135142
@cli.register_custom_action("ProjectIssue")
136143
@exc.on_http_error(exc.GitlabGetError)
137-
defrelated_merge_requests(self,**kwargs):
144+
defrelated_merge_requests(self,**kwargs:Any)->Dict[str,Any]:
138145
"""List merge requests related to the issue.
139146
140147
Args:
@@ -148,11 +155,14 @@ def related_merge_requests(self, **kwargs):
148155
list: The list of merge requests.
149156
"""
150157
path=f"{self.manager.path}/{self.get_id()}/related_merge_requests"
151-
returnself.manager.gitlab.http_get(path,**kwargs)
158+
result=self.manager.gitlab.http_get(path,**kwargs)
159+
ifTYPE_CHECKING:
160+
assertisinstance(result,dict)
161+
returnresult
152162

153163
@cli.register_custom_action("ProjectIssue")
154164
@exc.on_http_error(exc.GitlabGetError)
155-
defclosed_by(self,**kwargs):
165+
defclosed_by(self,**kwargs:Any)->Dict[str,Any]:
156166
"""List merge requests that will close the issue when merged.
157167
158168
Args:
@@ -166,7 +176,10 @@ def closed_by(self, **kwargs):
166176
list: The list of merge requests.
167177
"""
168178
path=f"{self.manager.path}/{self.get_id()}/closed_by"
169-
returnself.manager.gitlab.http_get(path,**kwargs)
179+
result=self.manager.gitlab.http_get(path,**kwargs)
180+
ifTYPE_CHECKING:
181+
assertisinstance(result,dict)
182+
returnresult
170183

171184

172185
classProjectIssueManager(CRUDMixin,RESTManager):
@@ -222,6 +235,11 @@ class ProjectIssueManager(CRUDMixin, RESTManager):
222235
)
223236
_types= {"iids":types.ListAttribute,"labels":types.ListAttribute}
224237

238+
defget(
239+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
240+
)->ProjectIssue:
241+
returncast(ProjectIssue,super().get(id=id,lazy=lazy,**kwargs))
242+
225243

226244
classProjectIssueLink(ObjectDeleteMixin,RESTObject):
227245
_id_attr="issue_link_id"
@@ -234,7 +252,11 @@ class ProjectIssueLinkManager(ListMixin, CreateMixin, DeleteMixin, RESTManager):
234252
_create_attrs=RequiredOptional(required=("target_project_id","target_issue_iid"))
235253

236254
@exc.on_http_error(exc.GitlabCreateError)
237-
defcreate(self,data,**kwargs):
255+
# NOTE(jlvillal): Signature doesn't match CreateMixin.create() so ignore
256+
# type error
257+
defcreate(# type: ignore
258+
self,data:Dict[str,Any],**kwargs:Any
259+
)->Tuple[RESTObject,RESTObject]:
238260
"""Create a new object.
239261
240262
Args:
@@ -250,7 +272,12 @@ def create(self, data, **kwargs):
250272
GitlabCreateError: If the server cannot perform the request
251273
"""
252274
self._check_missing_create_attrs(data)
275+
ifTYPE_CHECKING:
276+
assertself.pathisnotNone
253277
server_data=self.gitlab.http_post(self.path,post_data=data,**kwargs)
278+
ifTYPE_CHECKING:
279+
assertisinstance(server_data,dict)
280+
assertself._parentisnotNone
254281
source_issue=ProjectIssue(self._parent.manager,server_data["source_issue"])
255282
target_issue=ProjectIssue(self._parent.manager,server_data["target_issue"])
256283
returnsource_issue,target_issue

‎pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module = [
1313
"docs.*",
1414
"docs.ext.*",
1515
"gitlab.v4.objects.files",
16-
"gitlab.v4.objects.issues",
1716
"gitlab.v4.objects.jobs",
1817
"gitlab.v4.objects.labels",
1918
"gitlab.v4.objects.milestones",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp