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

Commitedd01a5

Browse files
igorp-collaboranejch
authored andcommitted
chore: Remove trivial get methods in preparation for generic Get mixin
Currently because the Get mixin is not generic every subclass hasto implement its own `get` methods to type hint `get` method returnbeoynd the basic RESTObject.The upcoming PR will change Get mixin to use generics. This meansit will be able to type hint the corresponding `_obj_cls` and no`get` method would need to be redefined.Because removing existing `get` methods modifies a lot of filessplit it in to a separate commit.Also remove the `tests/unit/meta/test_ensure_type_hints.py` filebecause testing subclasses for `get` methods is no longer relevant.Signed-off-by: Igor Ponomarev <igor.ponomarev@collabora.com>
1 parent515a8a2 commitedd01a5

File tree

64 files changed

+27
-960
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+27
-960
lines changed

‎gitlab/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,10 +397,11 @@ def auth(self) -> None:
397397
The `user` attribute will hold a `gitlab.objects.CurrentUser` object on
398398
success.
399399
"""
400-
self.user=self._objects.CurrentUserManager(self).get()
400+
# pylint: disable=line-too-long
401+
self.user=self._objects.CurrentUserManager(self).get()# type: ignore[assignment]
401402

402403
ifhasattr(self.user,"web_url")andhasattr(self.user,"username"):
403-
self._check_url(self.user.web_url,path=self.user.username)
404+
self._check_url(self.user.web_url,path=self.user.username)# type: ignore[union-attr]
404405

405406
defversion(self)->Tuple[str,str]:
406407
"""Returns the version and revision of the gitlab server.

‎gitlab/v4/objects/appearance.py

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

33
fromgitlabimportexceptionsasexc
44
fromgitlab.baseimportRESTManager,RESTObject
@@ -58,6 +58,3 @@ def update(
5858
new_data=new_dataor {}
5959
data=new_data.copy()
6060
returnsuper().update(id,data,**kwargs)
61-
62-
defget(self,**kwargs:Any)->ApplicationAppearance:
63-
returncast(ApplicationAppearance,super().get(**kwargs))

‎gitlab/v4/objects/audit_events.py

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
https://docs.gitlab.com/ee/api/audit_events.html
44
"""
55

6-
fromtypingimportAny,cast,Union
7-
86
fromgitlab.baseimportRESTManager,RESTObject
97
fromgitlab.mixinsimportRetrieveMixin
108

@@ -29,9 +27,6 @@ class AuditEventManager(RetrieveMixin, RESTManager):
2927
_obj_cls=AuditEvent
3028
_list_filters= ("created_after","created_before","entity_type","entity_id")
3129

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

3631
classGroupAuditEvent(RESTObject):
3732
_id_attr="id"
@@ -43,11 +38,6 @@ class GroupAuditEventManager(RetrieveMixin, RESTManager):
4338
_from_parent_attrs= {"group_id":"id"}
4439
_list_filters= ("created_after","created_before")
4540

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

5242
classProjectAuditEvent(RESTObject):
5343
_id_attr="id"
@@ -59,11 +49,6 @@ class ProjectAuditEventManager(RetrieveMixin, RESTManager):
5949
_from_parent_attrs= {"project_id":"id"}
6050
_list_filters= ("created_after","created_before")
6151

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

6853
classProjectAudit(ProjectAuditEvent):
6954
pass

‎gitlab/v4/objects/award_emojis.py

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
fromtypingimportAny,cast,Union
2-
31
fromgitlab.baseimportRESTManager,RESTObject
42
fromgitlab.mixinsimportNoUpdateMixin,ObjectDeleteMixin
53
fromgitlab.typesimportRequiredOptional
@@ -34,11 +32,6 @@ class GroupEpicAwardEmojiManager(NoUpdateMixin, RESTManager):
3432
_from_parent_attrs= {"group_id":"group_id","epic_iid":"iid"}
3533
_create_attrs=RequiredOptional(required=("name",))
3634

37-
defget(
38-
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
39-
)->GroupEpicAwardEmoji:
40-
returncast(GroupEpicAwardEmoji,super().get(id=id,lazy=lazy,**kwargs))
41-
4235

4336
classGroupEpicNoteAwardEmoji(ObjectDeleteMixin,RESTObject):
4437
pass
@@ -54,11 +47,6 @@ class GroupEpicNoteAwardEmojiManager(NoUpdateMixin, RESTManager):
5447
}
5548
_create_attrs=RequiredOptional(required=("name",))
5649

57-
defget(
58-
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
59-
)->GroupEpicNoteAwardEmoji:
60-
returncast(GroupEpicNoteAwardEmoji,super().get(id=id,lazy=lazy,**kwargs))
61-
6250

6351
classProjectIssueAwardEmoji(ObjectDeleteMixin,RESTObject):
6452
pass
@@ -70,11 +58,6 @@ class ProjectIssueAwardEmojiManager(NoUpdateMixin, RESTManager):
7058
_from_parent_attrs= {"project_id":"project_id","issue_iid":"iid"}
7159
_create_attrs=RequiredOptional(required=("name",))
7260

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

7962
classProjectIssueNoteAwardEmoji(ObjectDeleteMixin,RESTObject):
8063
pass
@@ -90,11 +73,6 @@ class ProjectIssueNoteAwardEmojiManager(NoUpdateMixin, RESTManager):
9073
}
9174
_create_attrs=RequiredOptional(required=("name",))
9275

93-
defget(
94-
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
95-
)->ProjectIssueNoteAwardEmoji:
96-
returncast(ProjectIssueNoteAwardEmoji,super().get(id=id,lazy=lazy,**kwargs))
97-
9876

9977
classProjectMergeRequestAwardEmoji(ObjectDeleteMixin,RESTObject):
10078
pass
@@ -106,13 +84,6 @@ class ProjectMergeRequestAwardEmojiManager(NoUpdateMixin, RESTManager):
10684
_from_parent_attrs= {"project_id":"project_id","mr_iid":"iid"}
10785
_create_attrs=RequiredOptional(required=("name",))
10886

109-
defget(
110-
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
111-
)->ProjectMergeRequestAwardEmoji:
112-
returncast(
113-
ProjectMergeRequestAwardEmoji,super().get(id=id,lazy=lazy,**kwargs)
114-
)
115-
11687

11788
classProjectMergeRequestNoteAwardEmoji(ObjectDeleteMixin,RESTObject):
11889
pass
@@ -128,13 +99,6 @@ class ProjectMergeRequestNoteAwardEmojiManager(NoUpdateMixin, RESTManager):
12899
}
129100
_create_attrs=RequiredOptional(required=("name",))
130101

131-
defget(
132-
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
133-
)->ProjectMergeRequestNoteAwardEmoji:
134-
returncast(
135-
ProjectMergeRequestNoteAwardEmoji,super().get(id=id,lazy=lazy,**kwargs)
136-
)
137-
138102

139103
classProjectSnippetAwardEmoji(ObjectDeleteMixin,RESTObject):
140104
pass
@@ -146,11 +110,6 @@ class ProjectSnippetAwardEmojiManager(NoUpdateMixin, RESTManager):
146110
_from_parent_attrs= {"project_id":"project_id","snippet_id":"id"}
147111
_create_attrs=RequiredOptional(required=("name",))
148112

149-
defget(
150-
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
151-
)->ProjectSnippetAwardEmoji:
152-
returncast(ProjectSnippetAwardEmoji,super().get(id=id,lazy=lazy,**kwargs))
153-
154113

155114
classProjectSnippetNoteAwardEmoji(ObjectDeleteMixin,RESTObject):
156115
pass
@@ -165,10 +124,3 @@ class ProjectSnippetNoteAwardEmojiManager(NoUpdateMixin, RESTManager):
165124
"note_id":"id",
166125
}
167126
_create_attrs=RequiredOptional(required=("name",))
168-
169-
defget(
170-
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
171-
)->ProjectSnippetNoteAwardEmoji:
172-
returncast(
173-
ProjectSnippetNoteAwardEmoji,super().get(id=id,lazy=lazy,**kwargs)
174-
)

‎gitlab/v4/objects/badges.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
fromtypingimportAny,cast,Union
2-
31
fromgitlab.baseimportRESTManager,RESTObject
42
fromgitlab.mixinsimportBadgeRenderMixin,CRUDMixin,ObjectDeleteMixin,SaveMixin
53
fromgitlab.typesimportRequiredOptional
@@ -23,9 +21,6 @@ class GroupBadgeManager(BadgeRenderMixin, CRUDMixin, RESTManager):
2321
_create_attrs=RequiredOptional(required=("link_url","image_url"))
2422
_update_attrs=RequiredOptional(optional=("link_url","image_url"))
2523

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

3025
classProjectBadge(SaveMixin,ObjectDeleteMixin,RESTObject):
3126
pass
@@ -37,8 +32,3 @@ class ProjectBadgeManager(BadgeRenderMixin, CRUDMixin, RESTManager):
3732
_from_parent_attrs= {"project_id":"id"}
3833
_create_attrs=RequiredOptional(required=("link_url","image_url"))
3934
_update_attrs=RequiredOptional(optional=("link_url","image_url"))
40-
41-
defget(
42-
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
43-
)->ProjectBadge:
44-
returncast(ProjectBadge,super().get(id=id,lazy=lazy,**kwargs))

‎gitlab/v4/objects/boards.py

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
fromtypingimportAny,cast,Union
2-
31
fromgitlab.baseimportRESTManager,RESTObject
42
fromgitlab.mixinsimportCRUDMixin,ObjectDeleteMixin,SaveMixin
53
fromgitlab.typesimportRequiredOptional
@@ -29,11 +27,6 @@ class GroupBoardListManager(CRUDMixin, RESTManager):
2927
)
3028
_update_attrs=RequiredOptional(required=("position",))
3129

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

3831
classGroupBoard(SaveMixin,ObjectDeleteMixin,RESTObject):
3932
lists:GroupBoardListManager
@@ -45,9 +38,6 @@ class GroupBoardManager(CRUDMixin, RESTManager):
4538
_from_parent_attrs= {"group_id":"id"}
4639
_create_attrs=RequiredOptional(required=("name",))
4740

48-
defget(self,id:Union[str,int],lazy:bool=False,**kwargs:Any)->GroupBoard:
49-
returncast(GroupBoard,super().get(id=id,lazy=lazy,**kwargs))
50-
5141

5242
classProjectBoardList(SaveMixin,ObjectDeleteMixin,RESTObject):
5343
pass
@@ -62,11 +52,6 @@ class ProjectBoardListManager(CRUDMixin, RESTManager):
6252
)
6353
_update_attrs=RequiredOptional(required=("position",))
6454

65-
defget(
66-
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
67-
)->ProjectBoardList:
68-
returncast(ProjectBoardList,super().get(id=id,lazy=lazy,**kwargs))
69-
7055

7156
classProjectBoard(SaveMixin,ObjectDeleteMixin,RESTObject):
7257
lists:ProjectBoardListManager
@@ -77,8 +62,3 @@ class ProjectBoardManager(CRUDMixin, RESTManager):
7762
_obj_cls=ProjectBoard
7863
_from_parent_attrs= {"project_id":"id"}
7964
_create_attrs=RequiredOptional(required=("name",))
80-
81-
defget(
82-
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
83-
)->ProjectBoard:
84-
returncast(ProjectBoard,super().get(id=id,lazy=lazy,**kwargs))

‎gitlab/v4/objects/branches.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
fromtypingimportAny,cast,Union
2-
31
fromgitlab.baseimportRESTManager,RESTObject
42
fromgitlab.mixinsimport (
53
CRUDMixin,
@@ -28,11 +26,6 @@ class ProjectBranchManager(NoUpdateMixin, RESTManager):
2826
_from_parent_attrs= {"project_id":"id"}
2927
_create_attrs=RequiredOptional(required=("branch","ref"))
3028

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

3730
classProjectProtectedBranch(SaveMixin,ObjectDeleteMixin,RESTObject):
3831
_id_attr="name"
@@ -56,8 +49,3 @@ class ProjectProtectedBranchManager(CRUDMixin, RESTManager):
5649
),
5750
)
5851
_update_method=UpdateMethod.PATCH
59-
60-
defget(
61-
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
62-
)->ProjectProtectedBranch:
63-
returncast(ProjectProtectedBranch,super().get(id=id,lazy=lazy,**kwargs))

‎gitlab/v4/objects/broadcast_messages.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
fromtypingimportAny,cast,Union
2-
31
fromgitlab.baseimportRESTManager,RESTObject
42
fromgitlab.mixinsimportCRUDMixin,ObjectDeleteMixin,SaveMixin
53
fromgitlab.typesimportArrayAttribute,RequiredOptional
@@ -33,8 +31,3 @@ class BroadcastMessageManager(CRUDMixin, RESTManager):
3331
)
3432
)
3533
_types= {"target_access_levels":ArrayAttribute}
36-
37-
defget(
38-
self,id:Union[str,int],lazy:bool=False,**kwargs:Any
39-
)->BroadcastMessage:
40-
returncast(BroadcastMessage,super().get(id=id,lazy=lazy,**kwargs))

‎gitlab/v4/objects/bulk_imports.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
fromtypingimportAny,cast,Union
2-
31
fromgitlab.baseimportRESTManager,RESTObject
42
fromgitlab.mixinsimportCreateMixin,ListMixin,RefreshMixin,RetrieveMixin
53
fromgitlab.typesimportRequiredOptional
@@ -24,9 +22,6 @@ class BulkImportManager(CreateMixin, RetrieveMixin, RESTManager):
2422
_create_attrs=RequiredOptional(required=("configuration","entities"))
2523
_list_filters= ("sort","status")
2624

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

3126
classBulkImportEntity(RefreshMixin,RESTObject):
3227
pass
@@ -38,11 +33,6 @@ class BulkImportEntityManager(RetrieveMixin, RESTManager):
3833
_from_parent_attrs= {"bulk_import_id":"id"}
3934
_list_filters= ("sort","status")
4035

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

4737
classBulkImportAllEntity(RESTObject):
4838
pass

‎gitlab/v4/objects/ci_lint.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
https://docs.gitlab.com/ee/api/lint.html
44
"""
55

6-
fromtypingimportAny,cast
6+
fromtypingimportAny
77

88
fromgitlab.baseimportRESTManager,RESTObject
99
fromgitlab.cliimportregister_custom_action
@@ -59,9 +59,6 @@ class ProjectCiLintManager(GetWithoutIdMixin, CreateMixin, RESTManager):
5959
required=("content",),optional=("dry_run","include_jobs","ref")
6060
)
6161

62-
defget(self,**kwargs:Any)->ProjectCiLint:
63-
returncast(ProjectCiLint,super().get(**kwargs))
64-
6562
@register_custom_action(
6663
cls_names="ProjectCiLintManager",
6764
required=("content",),

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp