1- from typing import Any ,cast ,Dict ,Optional ,TYPE_CHECKING , Union
1+ from typing import Any ,cast ,Dict ,Optional ,Union
22
33from gitlab import exceptions as exc
44from gitlab .base import RequiredOptional ,RESTManager ,RESTObject
55from gitlab .mixins import (
66CreateMixin ,
77DeleteMixin ,
8- ListMixin ,
98ObjectDeleteMixin ,
109PromoteMixin ,
1110RetrieveMixin ,
@@ -47,7 +46,9 @@ def save(self, **kwargs: Any) -> None:
4746self ._update_attrs (server_data )
4847
4948
50- class GroupLabelManager (ListMixin ,CreateMixin ,UpdateMixin ,DeleteMixin ,RESTManager ):
49+ class GroupLabelManager (
50+ RetrieveMixin ,CreateMixin ,UpdateMixin ,DeleteMixin ,RESTManager
51+ ):
5152_path = "/groups/{group_id}/labels"
5253_obj_cls = GroupLabel
5354_from_parent_attrs = {"group_id" :"id" }
@@ -58,6 +59,9 @@ class GroupLabelManager(ListMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTMa
5859required = ("name" ,),optional = ("new_name" ,"color" ,"description" ,"priority" )
5960 )
6061
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+
6165# Update without ID.
6266# NOTE(jlvillal): Signature doesn't match UpdateMixin.update() so ignore
6367# type error
@@ -78,25 +82,6 @@ def update( # type: ignore
7882new_data ["name" ]= name
7983return super ().update (id = None ,new_data = new_data ,** kwargs )
8084
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-
10085
10186class ProjectLabel (
10287PromoteMixin ,SubscribableMixin ,SaveMixin ,ObjectDeleteMixin ,RESTObject
@@ -162,22 +147,3 @@ def update( # type: ignore
162147if name :
163148new_data ["name" ]= name
164149return 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 )