1
- from typing import Any , cast , Dict , Optional , TYPE_CHECKING , Union
1
+ from typing import Any , cast , Dict , Optional , Union
2
2
3
3
from gitlab import exceptions as exc
4
4
from gitlab .base import RequiredOptional , RESTManager , RESTObject
5
5
from gitlab .mixins import (
6
6
CreateMixin ,
7
7
DeleteMixin ,
8
- ListMixin ,
9
8
ObjectDeleteMixin ,
10
9
PromoteMixin ,
11
10
RetrieveMixin ,
@@ -47,7 +46,9 @@ def save(self, **kwargs: Any) -> None:
47
46
self ._update_attrs (server_data )
48
47
49
48
50
- class GroupLabelManager (ListMixin , CreateMixin , UpdateMixin , DeleteMixin , RESTManager ):
49
+ class GroupLabelManager (
50
+ RetrieveMixin , CreateMixin , UpdateMixin , DeleteMixin , RESTManager
51
+ ):
51
52
_path = "/groups/{group_id}/labels"
52
53
_obj_cls = GroupLabel
53
54
_from_parent_attrs = {"group_id" : "id" }
@@ -58,6 +59,9 @@ class GroupLabelManager(ListMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTMa
58
59
required = ("name" ,), optional = ("new_name" , "color" , "description" , "priority" )
59
60
)
60
61
62
+ def get (self , id : Union [str , int ], lazy : bool = False , ** kwargs : Any ) -> GroupLabel :
63
+ return cast (GroupLabel , super ().get (id = id , lazy = lazy , ** kwargs ))
64
+
61
65
# Update without ID.
62
66
# NOTE(jlvillal): Signature doesn't match UpdateMixin.update() so ignore
63
67
# type error
@@ -78,25 +82,6 @@ def update( # type: ignore
78
82
new_data ["name" ] = name
79
83
return super ().update (id = None , new_data = new_data , ** kwargs )
80
84
81
- # Delete without ID.
82
- @exc .on_http_error (exc .GitlabDeleteError )
83
- # NOTE(jlvillal): Signature doesn't match DeleteMixin.delete() so ignore
84
- # type error
85
- def delete (self , name : str , ** kwargs : Any ) -> None : # type: ignore
86
- """Delete a Label on the server.
87
-
88
- Args:
89
- name: The name of the label
90
- **kwargs: Extra options to send to the server (e.g. sudo)
91
-
92
- Raises:
93
- GitlabAuthenticationError: If authentication is not correct
94
- GitlabDeleteError: If the server cannot perform the request
95
- """
96
- if TYPE_CHECKING :
97
- assert self .path is not None
98
- self .gitlab .http_delete (self .path , query_data = {"name" : name }, ** kwargs )
99
-
100
85
101
86
class ProjectLabel (
102
87
PromoteMixin , SubscribableMixin , SaveMixin , ObjectDeleteMixin , RESTObject
@@ -162,22 +147,3 @@ def update( # type: ignore
162
147
if name :
163
148
new_data ["name" ] = name
164
149
return super ().update (id = None , new_data = new_data , ** kwargs )
165
-
166
- # Delete without ID.
167
- @exc .on_http_error (exc .GitlabDeleteError )
168
- # NOTE(jlvillal): Signature doesn't match DeleteMixin.delete() so ignore
169
- # type error
170
- def delete (self , name : str , ** kwargs : Any ) -> None : # type: ignore
171
- """Delete a Label on the server.
172
-
173
- Args:
174
- name: The name of the label
175
- **kwargs: Extra options to send to the server (e.g. sudo)
176
-
177
- Raises:
178
- GitlabAuthenticationError: If authentication is not correct
179
- GitlabDeleteError: If the server cannot perform the request
180
- """
181
- if TYPE_CHECKING :
182
- assert self .path is not None
183
- self .gitlab .http_delete (self .path , query_data = {"name" : name }, ** kwargs )
0 commit comments