From 8da0b758c589f608a6ae4eeb74b3f306609ba36d Mon Sep 17 00:00:00 2001 From: "John L. Villalovos" Date: Sun, 21 Nov 2021 14:28:07 -0800 Subject: [PATCH] chore: add type-hints to gitlab/v4/objects/services.py --- gitlab/v4/objects/services.py | 20 +++++++++++++++----- pyproject.toml | 1 - 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/gitlab/v4/objects/services.py b/gitlab/v4/objects/services.py index 3d7d37727..a62fdf0c2 100644 --- a/gitlab/v4/objects/services.py +++ b/gitlab/v4/objects/services.py @@ -1,3 +1,5 @@ +from typing import Any, cast, Dict, List, Optional, Union + from gitlab import cli from gitlab.base import RESTManager, RESTObject from gitlab.mixins import ( @@ -253,7 +255,9 @@ class ProjectServiceManager(GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTM "youtrack": (("issues_url", "project_url"), ("description", "push_events")), } - def get(self, id, **kwargs): + def get( + self, id: Union[str, int], lazy: bool = False, **kwargs: Any + ) -> ProjectService: """Retrieve a single object. Args: @@ -270,11 +274,16 @@ def get(self, id, **kwargs): GitlabAuthenticationError: If authentication is not correct GitlabGetError: If the server cannot perform the request """ - obj = super(ProjectServiceManager, self).get(id, **kwargs) + obj = cast(ProjectService, super(ProjectServiceManager, self).get(id, **kwargs)) obj.id = id return obj - def update(self, id=None, new_data=None, **kwargs): + def update( + self, + id: Optional[Union[str, int]] = None, + new_data: Optional[Dict[str, Any]] = None, + **kwargs: Any + ) -> Dict[str, Any]: """Update an object on the server. Args: @@ -290,11 +299,12 @@ def update(self, id=None, new_data=None, **kwargs): GitlabUpdateError: If the server cannot perform the request """ new_data = new_data or {} - super(ProjectServiceManager, self).update(id, new_data, **kwargs) + result = super(ProjectServiceManager, self).update(id, new_data, **kwargs) self.id = id + return result @cli.register_custom_action("ProjectServiceManager") - def available(self, **kwargs): + def available(self, **kwargs: Any) -> List[str]: """List the services known by python-gitlab. Returns: diff --git a/pyproject.toml b/pyproject.toml index 7fde0e289..d9cff740a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -14,7 +14,6 @@ module = [ "docs.ext.*", "gitlab.v4.objects.files", "gitlab.v4.objects.labels", - "gitlab.v4.objects.services", "gitlab.v4.objects.sidekiq", "tests.functional.*", "tests.functional.api.*",