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

Commitd4adf8d

Browse files
chore: add type-hints to gitlab/v4/objects/epics.py
1 parent9a451a8 commitd4adf8d

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

‎gitlab/v4/objects/epics.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromtypingimportAny,cast,Dict,Optional,TYPE_CHECKING,Union
2+
13
fromgitlabimportexceptionsasexc
24
fromgitlabimporttypes
35
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject
@@ -42,11 +44,17 @@ class GroupEpicManager(CRUDMixin, RESTManager):
4244
)
4345
_types= {"labels":types.ListAttribute}
4446

47+
defget(self,id:Union[str,int],lazy:bool=False,**kwargs:Any)->GroupEpic:
48+
returncast(GroupEpic,super().get(id=id,lazy=lazy,**kwargs))
49+
4550

4651
classGroupEpicIssue(ObjectDeleteMixin,SaveMixin,RESTObject):
4752
_id_attr="epic_issue_id"
53+
# Define type for 'manager' here So mypy won't complain about
54+
# 'self.manager.update()' call in the 'save' method.
55+
manager:"GroupEpicIssueManager"
4856

49-
defsave(self,**kwargs):
57+
defsave(self,**kwargs:Any)->None:
5058
"""Save the changes made to the object to the server.
5159
5260
The object is updated to match what the server returns.
@@ -78,7 +86,9 @@ class GroupEpicIssueManager(
7886
_update_attrs=RequiredOptional(optional=("move_before_id","move_after_id"))
7987

8088
@exc.on_http_error(exc.GitlabCreateError)
81-
defcreate(self,data,**kwargs):
89+
defcreate(
90+
self,data:Optional[Dict[str,Any]]=None,**kwargs:Any
91+
)->GroupEpicIssue:
8292
"""Create a new object.
8393
8494
Args:
@@ -94,9 +104,13 @@ def create(self, data, **kwargs):
94104
RESTObject: A new instance of the manage object class build with
95105
the data sent by the server
96106
"""
107+
ifTYPE_CHECKING:
108+
assertdataisnotNone
97109
CreateMixin._check_missing_create_attrs(self,data)
98110
path=f"{self.path}/{data.pop('issue_id')}"
99111
server_data=self.gitlab.http_post(path,**kwargs)
112+
ifTYPE_CHECKING:
113+
assertisinstance(server_data,dict)
100114
# The epic_issue_id attribute doesn't exist when creating the resource,
101115
# but is used everywhere elese. Let's create it to be consistent client
102116
# side

‎pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ files = "."
1212
module = [
1313
"docs.*",
1414
"docs.ext.*",
15-
"gitlab.v4.objects.epics",
1615
"gitlab.v4.objects.files",
1716
"gitlab.v4.objects.geo_nodes",
1817
"gitlab.v4.objects.issues",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp