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

Commit0951989

Browse files
authored
Merge pull request#1681 from python-gitlab/jlvillal/mypy_ensure_type_hints
Ensure get() methods have correct type-hints
2 parentsa553ee7 +46773a8 commit0951989

25 files changed

+437
-6
lines changed

‎gitlab/v4/objects/audit_events.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
GitLab API:
33
https://docs.gitlab.com/ee/api/audit_events.html
44
"""
5+
fromtypingimportAny,cast,Union
6+
57
fromgitlab.baseimportRESTManager,RESTObject
68
fromgitlab.mixinsimportRetrieveMixin
79

@@ -26,6 +28,9 @@ class AuditEventManager(RetrieveMixin, RESTManager):
2628
_obj_cls=AuditEvent
2729
_list_filters= ("created_after","created_before","entity_type","entity_id")
2830

31+
defget(self,id:Union[str,int],lazy:bool=False,**kwargs:Any)->AuditEvent:
32+
returncast(AuditEvent,super().get(id=id,lazy=lazy,**kwargs))
33+
2934

3035
classGroupAuditEvent(RESTObject):
3136
_id_attr="id"
@@ -37,6 +42,11 @@ class GroupAuditEventManager(RetrieveMixin, RESTManager):
3742
_from_parent_attrs= {"group_id":"id"}
3843
_list_filters= ("created_after","created_before")
3944

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

4151
classProjectAuditEvent(RESTObject):
4252
_id_attr="id"
@@ -48,6 +58,11 @@ class ProjectAuditEventManager(RetrieveMixin, RESTManager):
4858
_from_parent_attrs= {"project_id":"id"}
4959
_list_filters= ("created_after","created_before")
5060

61+
defget(
62+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
63+
)->ProjectAuditEvent:
64+
returncast(ProjectAuditEvent,super().get(id=id,lazy=lazy,**kwargs))
65+
5166

5267
classProjectAudit(ProjectAuditEvent):
5368
pass

‎gitlab/v4/objects/award_emojis.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromtypingimportAny,cast,Union
2+
13
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject
24
fromgitlab.mixinsimportNoUpdateMixin,ObjectDeleteMixin
35

@@ -27,6 +29,11 @@ class ProjectIssueAwardEmojiManager(NoUpdateMixin, RESTManager):
2729
_from_parent_attrs= {"project_id":"project_id","issue_iid":"iid"}
2830
_create_attrs=RequiredOptional(required=("name",))
2931

32+
defget(
33+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
34+
)->ProjectIssueAwardEmoji:
35+
returncast(ProjectIssueAwardEmoji,super().get(id=id,lazy=lazy,**kwargs))
36+
3037

3138
classProjectIssueNoteAwardEmoji(ObjectDeleteMixin,RESTObject):
3239
pass
@@ -42,6 +49,11 @@ class ProjectIssueNoteAwardEmojiManager(NoUpdateMixin, RESTManager):
4249
}
4350
_create_attrs=RequiredOptional(required=("name",))
4451

52+
defget(
53+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
54+
)->ProjectIssueNoteAwardEmoji:
55+
returncast(ProjectIssueNoteAwardEmoji,super().get(id=id,lazy=lazy,**kwargs))
56+
4557

4658
classProjectMergeRequestAwardEmoji(ObjectDeleteMixin,RESTObject):
4759
pass
@@ -53,6 +65,13 @@ class ProjectMergeRequestAwardEmojiManager(NoUpdateMixin, RESTManager):
5365
_from_parent_attrs= {"project_id":"project_id","mr_iid":"iid"}
5466
_create_attrs=RequiredOptional(required=("name",))
5567

68+
defget(
69+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
70+
)->ProjectMergeRequestAwardEmoji:
71+
returncast(
72+
ProjectMergeRequestAwardEmoji,super().get(id=id,lazy=lazy,**kwargs)
73+
)
74+
5675

5776
classProjectMergeRequestNoteAwardEmoji(ObjectDeleteMixin,RESTObject):
5877
pass
@@ -68,6 +87,13 @@ class ProjectMergeRequestNoteAwardEmojiManager(NoUpdateMixin, RESTManager):
6887
}
6988
_create_attrs=RequiredOptional(required=("name",))
7089

90+
defget(
91+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
92+
)->ProjectMergeRequestNoteAwardEmoji:
93+
returncast(
94+
ProjectMergeRequestNoteAwardEmoji,super().get(id=id,lazy=lazy,**kwargs)
95+
)
96+
7197

7298
classProjectSnippetAwardEmoji(ObjectDeleteMixin,RESTObject):
7399
pass
@@ -79,6 +105,11 @@ class ProjectSnippetAwardEmojiManager(NoUpdateMixin, RESTManager):
79105
_from_parent_attrs= {"project_id":"project_id","snippet_id":"id"}
80106
_create_attrs=RequiredOptional(required=("name",))
81107

108+
defget(
109+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
110+
)->ProjectSnippetAwardEmoji:
111+
returncast(ProjectSnippetAwardEmoji,super().get(id=id,lazy=lazy,**kwargs))
112+
82113

83114
classProjectSnippetNoteAwardEmoji(ObjectDeleteMixin,RESTObject):
84115
pass
@@ -93,3 +124,10 @@ class ProjectSnippetNoteAwardEmojiManager(NoUpdateMixin, RESTManager):
93124
"note_id":"id",
94125
}
95126
_create_attrs=RequiredOptional(required=("name",))
127+
128+
defget(
129+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
130+
)->ProjectSnippetNoteAwardEmoji:
131+
returncast(
132+
ProjectSnippetNoteAwardEmoji,super().get(id=id,lazy=lazy,**kwargs)
133+
)

‎gitlab/v4/objects/badges.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class GroupBadgeManager(BadgeRenderMixin, CRUDMixin, RESTManager):
2222
_create_attrs=RequiredOptional(required=("link_url","image_url"))
2323
_update_attrs=RequiredOptional(optional=("link_url","image_url"))
2424

25+
defget(self,id:Union[str,int],lazy:bool=False,**kwargs:Any)->GroupBadge:
26+
returncast(GroupBadge,super().get(id=id,lazy=lazy,**kwargs))
27+
2528

2629
classProjectBadge(SaveMixin,ObjectDeleteMixin,RESTObject):
2730
pass

‎gitlab/v4/objects/branches.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromtypingimportAny,cast,Union
2+
13
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject
24
fromgitlab.mixinsimportNoUpdateMixin,ObjectDeleteMixin
35

@@ -19,6 +21,11 @@ class ProjectBranchManager(NoUpdateMixin, RESTManager):
1921
_from_parent_attrs= {"project_id":"id"}
2022
_create_attrs=RequiredOptional(required=("branch","ref"))
2123

24+
defget(
25+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
26+
)->ProjectBranch:
27+
returncast(ProjectBranch,super().get(id=id,lazy=lazy,**kwargs))
28+
2229

2330
classProjectProtectedBranch(ObjectDeleteMixin,RESTObject):
2431
_id_attr="name"
@@ -40,3 +47,8 @@ class ProjectProtectedBranchManager(NoUpdateMixin, RESTManager):
4047
"code_owner_approval_required",
4148
),
4249
)
50+
51+
defget(
52+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
53+
)->ProjectProtectedBranch:
54+
returncast(ProjectProtectedBranch,super().get(id=id,lazy=lazy,**kwargs))

‎gitlab/v4/objects/clusters.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fromtypingimportAny,cast,Dict,Optional
1+
fromtypingimportAny,cast,Dict,Optional,Union
22

33
fromgitlabimportexceptionsasexc
44
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject
@@ -57,6 +57,11 @@ def create(
5757
path=f"{self.path}/user"
5858
returncast(GroupCluster,CreateMixin.create(self,data,path=path,**kwargs))
5959

60+
defget(
61+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
62+
)->GroupCluster:
63+
returncast(GroupCluster,super().get(id=id,lazy=lazy,**kwargs))
64+
6065

6166
classProjectCluster(SaveMixin,ObjectDeleteMixin,RESTObject):
6267
pass
@@ -102,3 +107,8 @@ def create(
102107
"""
103108
path=f"{self.path}/user"
104109
returncast(ProjectCluster,CreateMixin.create(self,data,path=path,**kwargs))
110+
111+
defget(
112+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
113+
)->ProjectCluster:
114+
returncast(ProjectCluster,super().get(id=id,lazy=lazy,**kwargs))

‎gitlab/v4/objects/commits.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ class ProjectCommitManager(RetrieveMixin, CreateMixin, RESTManager):
151151
optional=("author_email","author_name"),
152152
)
153153

154+
defget(
155+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
156+
)->ProjectCommit:
157+
returncast(ProjectCommit,super().get(id=id,lazy=lazy,**kwargs))
158+
154159

155160
classProjectCommitComment(RESTObject):
156161
_id_attr=None

‎gitlab/v4/objects/container_registry.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fromtypingimportAny,TYPE_CHECKING
1+
fromtypingimportAny,cast,TYPE_CHECKING,Union
22

33
fromgitlabimportcli
44
fromgitlabimportexceptionsasexc
@@ -60,3 +60,8 @@ def delete_in_bulk(self, name_regex_delete: str, **kwargs: Any) -> None:
6060
ifTYPE_CHECKING:
6161
assertself.pathisnotNone
6262
self.gitlab.http_delete(self.path,query_data=data,**kwargs)
63+
64+
defget(
65+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
66+
)->ProjectRegistryTag:
67+
returncast(ProjectRegistryTag,super().get(id=id,lazy=lazy,**kwargs))

‎gitlab/v4/objects/custom_attributes.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromtypingimportAny,cast,Union
2+
13
fromgitlab.baseimportRESTManager,RESTObject
24
fromgitlab.mixinsimportDeleteMixin,ObjectDeleteMixin,RetrieveMixin,SetMixin
35

@@ -20,6 +22,11 @@ class GroupCustomAttributeManager(RetrieveMixin, SetMixin, DeleteMixin, RESTMana
2022
_obj_cls=GroupCustomAttribute
2123
_from_parent_attrs= {"group_id":"id"}
2224

25+
defget(
26+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
27+
)->GroupCustomAttribute:
28+
returncast(GroupCustomAttribute,super().get(id=id,lazy=lazy,**kwargs))
29+
2330

2431
classProjectCustomAttribute(ObjectDeleteMixin,RESTObject):
2532
_id_attr="key"
@@ -30,6 +37,11 @@ class ProjectCustomAttributeManager(RetrieveMixin, SetMixin, DeleteMixin, RESTMa
3037
_obj_cls=ProjectCustomAttribute
3138
_from_parent_attrs= {"project_id":"id"}
3239

40+
defget(
41+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
42+
)->ProjectCustomAttribute:
43+
returncast(ProjectCustomAttribute,super().get(id=id,lazy=lazy,**kwargs))
44+
3345

3446
classUserCustomAttribute(ObjectDeleteMixin,RESTObject):
3547
_id_attr="key"
@@ -39,3 +51,8 @@ class UserCustomAttributeManager(RetrieveMixin, SetMixin, DeleteMixin, RESTManag
3951
_path="/users/{user_id}/custom_attributes"
4052
_obj_cls=UserCustomAttribute
4153
_from_parent_attrs= {"user_id":"id"}
54+
55+
defget(
56+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
57+
)->UserCustomAttribute:
58+
returncast(UserCustomAttribute,super().get(id=id,lazy=lazy,**kwargs))

‎gitlab/v4/objects/deployments.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromtypingimportAny,cast,Union
2+
13
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject
24
fromgitlab.mixinsimportCreateMixin,RetrieveMixin,SaveMixin,UpdateMixin
35

@@ -28,3 +30,8 @@ class ProjectDeploymentManager(RetrieveMixin, CreateMixin, UpdateMixin, RESTMana
2830
_create_attrs=RequiredOptional(
2931
required=("sha","ref","tag","status","environment")
3032
)
33+
34+
defget(
35+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
36+
)->ProjectDeployment:
37+
returncast(ProjectDeployment,super().get(id=id,lazy=lazy,**kwargs))

‎gitlab/v4/objects/discussions.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
fromtypingimportAny,cast,Union
2+
13
fromgitlab.baseimportRequiredOptional,RESTManager,RESTObject
24
fromgitlab.mixinsimportCreateMixin,RetrieveMixin,SaveMixin,UpdateMixin
35

@@ -30,6 +32,11 @@ class ProjectCommitDiscussionManager(RetrieveMixin, CreateMixin, RESTManager):
3032
_from_parent_attrs= {"project_id":"project_id","commit_id":"id"}
3133
_create_attrs=RequiredOptional(required=("body",),optional=("created_at",))
3234

35+
defget(
36+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
37+
)->ProjectCommitDiscussion:
38+
returncast(ProjectCommitDiscussion,super().get(id=id,lazy=lazy,**kwargs))
39+
3340

3441
classProjectIssueDiscussion(RESTObject):
3542
notes:ProjectIssueDiscussionNoteManager
@@ -41,6 +48,11 @@ class ProjectIssueDiscussionManager(RetrieveMixin, CreateMixin, RESTManager):
4148
_from_parent_attrs= {"project_id":"project_id","issue_iid":"iid"}
4249
_create_attrs=RequiredOptional(required=("body",),optional=("created_at",))
4350

51+
defget(
52+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
53+
)->ProjectIssueDiscussion:
54+
returncast(ProjectIssueDiscussion,super().get(id=id,lazy=lazy,**kwargs))
55+
4456

4557
classProjectMergeRequestDiscussion(SaveMixin,RESTObject):
4658
notes:ProjectMergeRequestDiscussionNoteManager
@@ -57,6 +69,13 @@ class ProjectMergeRequestDiscussionManager(
5769
)
5870
_update_attrs=RequiredOptional(required=("resolved",))
5971

72+
defget(
73+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
74+
)->ProjectMergeRequestDiscussion:
75+
returncast(
76+
ProjectMergeRequestDiscussion,super().get(id=id,lazy=lazy,**kwargs)
77+
)
78+
6079

6180
classProjectSnippetDiscussion(RESTObject):
6281
notes:ProjectSnippetDiscussionNoteManager
@@ -67,3 +86,8 @@ class ProjectSnippetDiscussionManager(RetrieveMixin, CreateMixin, RESTManager):
6786
_obj_cls=ProjectSnippetDiscussion
6887
_from_parent_attrs= {"project_id":"project_id","snippet_id":"id"}
6988
_create_attrs=RequiredOptional(required=("body",),optional=("created_at",))
89+
90+
defget(
91+
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
92+
)->ProjectSnippetDiscussion:
93+
returncast(ProjectSnippetDiscussion,super().get(id=id,lazy=lazy,**kwargs))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp