From 46773a82565cef231dc3391c12f296ac307cb95c Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Sun, 7 Nov 2021 14:33:39 -0800 Subject: chore: ensure get() methods have correct 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. --- gitlab/v4/objects/hooks.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gitlab/v4/objects/hooks.py') diff --git a/gitlab/v4/objects/hooks.py b/gitlab/v4/objects/hooks.py index 00dcfee..0b0092e 100644 --- a/gitlab/v4/objects/hooks.py +++ b/gitlab/v4/objects/hooks.py @@ -1,3 +1,5 @@ +from typing import Any, cast, Union + from gitlab.base import RequiredOptional, RESTManager, RESTObject from gitlab.mixins import CRUDMixin, NoUpdateMixin, ObjectDeleteMixin, SaveMixin @@ -21,6 +23,9 @@ class HookManager(NoUpdateMixin, RESTManager): _obj_cls = Hook _create_attrs = RequiredOptional(required=("url",)) + def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> Hook: + return cast(Hook, super().get(id=id, lazy=lazy, **kwargs)) + class ProjectHook(SaveMixin, ObjectDeleteMixin, RESTObject): _short_print_attr = "url" @@ -63,6 +68,11 @@ class ProjectHookManager(CRUDMixin, RESTManager): ), ) + def get( + self, id: Union[str, int], lazy: bool = False, **kwargs: Any + ) -> ProjectHook: + return cast(ProjectHook, super().get(id=id, lazy=lazy, **kwargs)) + class GroupHook(SaveMixin, ObjectDeleteMixin, RESTObject): _short_print_attr = "url" @@ -112,3 +122,6 @@ class GroupHookManager(CRUDMixin, RESTManager): "token", ), ) + + def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> GroupHook: + return cast(GroupHook, super().get(id=id, lazy=lazy, **kwargs)) -- cgit v1.2.1