Skip to content

Commit 05ff81d

Browse files
fix: remove custom delete method for labels
The usage of deleting was incorrect according to the current API. Closes: #1867
1 parent 7646360 commit 05ff81d

3 files changed

Lines changed: 11 additions & 41 deletions

File tree

‎gitlab/v4/objects/labels.py‎

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, cast, Dict, Optional, TYPE_CHECKING, Union
1+
from typing import Any, cast, Dict, Optional, Union
22

33
from gitlab import exceptions as exc
44
from gitlab.base import RequiredOptional, RESTManager, RESTObject
@@ -78,25 +78,6 @@ def update( # type: ignore
7878
new_data["name"] = name
7979
return super().update(id=None, new_data=new_data, **kwargs)
8080

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-
10081

10182
class ProjectLabel(
10283
PromoteMixin, SubscribableMixin, SaveMixin, ObjectDeleteMixin, RESTObject
@@ -162,22 +143,3 @@ def update( # type: ignore
162143
if name:
163144
new_data["name"] = name
164145
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)

‎tests/functional/api/test_groups.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ def test_group_labels(group):
116116
assert label.description == "baz"
117117
assert len(group.labels.list()) == 1
118118

119+
label.new_name = "comp:Flat Export"
120+
label.save()
121+
assert label.name == "comp:Flat Export"
122+
label = group.labels.get("comp:Flat Export")
123+
assert label.name == "comp:Flat Export"
124+
119125
label.delete()
120126
assert len(group.labels.list()) == 0
121127

‎tests/functional/api/test_projects.py‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,11 @@ def test_project_labels(project):
146146
label = project.labels.get("label")
147147
assert label == labels[0]
148148

149-
label.new_name = "labelupdated"
149+
label.new_name = "comp:Flat Export"
150150
label.save()
151-
assert label.name == "labelupdated"
151+
assert label.name == "comp:Flat Export"
152+
label = project.labels.get("comp:Flat Export")
153+
assert label.name == "comp:Flat Export"
152154

153155
label.subscribe()
154156
assert label.subscribed is True

0 commit comments

Comments
 (0)