summaryrefslogtreecommitdiff
path: root/gitlab/v4/objects/custom_attributes.py
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2021-11-07 14:33:39 -0800
committerJohn L. Villalovos <john@sodarock.com>2021-11-15 14:31:12 -0800
commit46773a82565cef231dc3391c12f296ac307cb95c (patch)
tree32cc9473ec28cc3d10be3baff28a74e8a17ac718 /gitlab/v4/objects/custom_attributes.py
parent94feb8a5534d43a464b717275846faa75783427e (diff)
downloadgitlab-46773a82565cef231dc3391c12f296ac307cb95c.tar.gz
chore: ensure get() methods have correct type-hintsjlvillal/mypy_ensure_type_hints
Fix classes which don't have correct 'get()' methods for classes derived from GetMixin. Add a unit test which verifies that classes have the correct return type in their 'get()' method.
Diffstat (limited to 'gitlab/v4/objects/custom_attributes.py')
-rw-r--r--gitlab/v4/objects/custom_attributes.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/gitlab/v4/objects/custom_attributes.py b/gitlab/v4/objects/custom_attributes.py
index aed1965..d061614 100644
--- a/gitlab/v4/objects/custom_attributes.py
+++ b/gitlab/v4/objects/custom_attributes.py
@@ -1,3 +1,5 @@
+from typing import Any, cast, Union
+
from gitlab.base import RESTManager, RESTObject
from gitlab.mixins import DeleteMixin, ObjectDeleteMixin, RetrieveMixin, SetMixin
@@ -20,6 +22,11 @@ class GroupCustomAttributeManager(RetrieveMixin, SetMixin, DeleteMixin, RESTMana
_obj_cls = GroupCustomAttribute
_from_parent_attrs = {"group_id": "id"}
+ def get(
+ self, id: Union[str, int], lazy: bool = False, **kwargs: Any
+ ) -> GroupCustomAttribute:
+ return cast(GroupCustomAttribute, super().get(id=id, lazy=lazy, **kwargs))
+
class ProjectCustomAttribute(ObjectDeleteMixin, RESTObject):
_id_attr = "key"
@@ -30,6 +37,11 @@ class ProjectCustomAttributeManager(RetrieveMixin, SetMixin, DeleteMixin, RESTMa
_obj_cls = ProjectCustomAttribute
_from_parent_attrs = {"project_id": "id"}
+ def get(
+ self, id: Union[str, int], lazy: bool = False, **kwargs: Any
+ ) -> ProjectCustomAttribute:
+ return cast(ProjectCustomAttribute, super().get(id=id, lazy=lazy, **kwargs))
+
class UserCustomAttribute(ObjectDeleteMixin, RESTObject):
_id_attr = "key"
@@ -39,3 +51,8 @@ class UserCustomAttributeManager(RetrieveMixin, SetMixin, DeleteMixin, RESTManag
_path = "/users/{user_id}/custom_attributes"
_obj_cls = UserCustomAttribute
_from_parent_attrs = {"user_id": "id"}
+
+ def get(
+ self, id: Union[str, int], lazy: bool = False, **kwargs: Any
+ ) -> UserCustomAttribute:
+ return cast(UserCustomAttribute, super().get(id=id, lazy=lazy, **kwargs))