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

fix: remove customdelete method for labels#1868

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
nejch merged 1 commit intomainfromjlvillal/delete_label
Feb 1, 2022
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 7 additions & 41 deletionsgitlab/v4/objects/labels.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
from typing import Any, cast, Dict, Optional,TYPE_CHECKING,Union
from typing import Any, cast, Dict, Optional, Union

from gitlab import exceptions as exc
from gitlab.base import RequiredOptional, RESTManager, RESTObject
from gitlab.mixins import (
CreateMixin,
DeleteMixin,
ListMixin,
ObjectDeleteMixin,
PromoteMixin,
RetrieveMixin,
Expand DownExpand Up@@ -47,7 +46,9 @@ def save(self, **kwargs: Any) -> None:
self._update_attrs(server_data)


class GroupLabelManager(ListMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager):
class GroupLabelManager(
RetrieveMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTManager
):
_path = "/groups/{group_id}/labels"
_obj_cls = GroupLabel
_from_parent_attrs = {"group_id": "id"}
Expand All@@ -58,6 +59,9 @@ class GroupLabelManager(ListMixin, CreateMixin, UpdateMixin, DeleteMixin, RESTMa
required=("name",), optional=("new_name", "color", "description", "priority")
)

def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> GroupLabel:
return cast(GroupLabel, super().get(id=id, lazy=lazy, **kwargs))

# Update without ID.
# NOTE(jlvillal): Signature doesn't match UpdateMixin.update() so ignore
# type error
Expand All@@ -78,25 +82,6 @@ def update( # type: ignore
new_data["name"] = name
return super().update(id=None, new_data=new_data, **kwargs)

# Delete without ID.
@exc.on_http_error(exc.GitlabDeleteError)
# NOTE(jlvillal): Signature doesn't match DeleteMixin.delete() so ignore
# type error
def delete(self, name: str, **kwargs: Any) -> None: # type: ignore
"""Delete a Label on the server.

Args:
name: The name of the label
**kwargs: Extra options to send to the server (e.g. sudo)

Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabDeleteError: If the server cannot perform the request
"""
if TYPE_CHECKING:
assert self.path is not None
self.gitlab.http_delete(self.path, query_data={"name": name}, **kwargs)


class ProjectLabel(
PromoteMixin, SubscribableMixin, SaveMixin, ObjectDeleteMixin, RESTObject
Expand DownExpand Up@@ -162,22 +147,3 @@ def update( # type: ignore
if name:
new_data["name"] = name
return super().update(id=None, new_data=new_data, **kwargs)

# Delete without ID.
@exc.on_http_error(exc.GitlabDeleteError)
# NOTE(jlvillal): Signature doesn't match DeleteMixin.delete() so ignore
# type error
def delete(self, name: str, **kwargs: Any) -> None: # type: ignore
"""Delete a Label on the server.

Args:
name: The name of the label
**kwargs: Extra options to send to the server (e.g. sudo)

Raises:
GitlabAuthenticationError: If authentication is not correct
GitlabDeleteError: If the server cannot perform the request
"""
if TYPE_CHECKING:
assert self.path is not None
self.gitlab.http_delete(self.path, query_data={"name": name}, **kwargs)
7 changes: 6 additions & 1 deletiontests/functional/api/test_groups.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -104,7 +104,6 @@ def test_groups(gl):
group2.members.delete(gl.user.id)


@pytest.mark.skip(reason="Commented out in legacy test")
def test_group_labels(group):
group.labels.create({"name": "foo", "description": "bar", "color": "#112233"})
label = group.labels.get("foo")
Expand All@@ -116,6 +115,12 @@ def test_group_labels(group):
assert label.description == "baz"
assert len(group.labels.list()) == 1

label.new_name = "Label:that requires:encoding"
label.save()
assert label.name == "Label:that requires:encoding"
label = group.labels.get("Label:that requires:encoding")
assert label.name == "Label:that requires:encoding"

label.delete()
assert len(group.labels.list()) == 0

Expand Down
6 changes: 4 additions & 2 deletionstests/functional/api/test_projects.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -146,9 +146,11 @@ def test_project_labels(project):
label = project.labels.get("label")
assert label == labels[0]

label.new_name = "labelupdated"
label.new_name = "Label:that requires:encoding"
label.save()
assert label.name == "labelupdated"
assert label.name == "Label:that requires:encoding"
label = project.labels.get("Label:that requires:encoding")
assert label.name == "Label:that requires:encoding"

label.subscribe()
assert label.subscribed is True
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp