Skip to content

Commit d75abd8

Browse files
chore: add type-hints to gitlab/v4/objects/services.py
1 parent 3365866 commit d75abd8

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

gitlab/v4/objects/services.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Any, cast, Dict, List, Optional, Union
2+
13
from gitlab import cli
24
from gitlab.base import RESTManager, RESTObject
35
from gitlab.mixins import (
@@ -253,7 +255,9 @@ class ProjectServiceManager(GetMixin, UpdateMixin, DeleteMixin, ListMixin, RESTM
253255
"youtrack": (("issues_url", "project_url"), ("description", "push_events")),
254256
}
255257

256-
def get(self, id, **kwargs):
258+
def get(
259+
self, id: Union[str, int], lazy: bool = False, **kwargs: Any
260+
) -> ProjectService:
257261
"""Retrieve a single object.
258262
259263
Args:
@@ -270,11 +274,16 @@ def get(self, id, **kwargs):
270274
GitlabAuthenticationError: If authentication is not correct
271275
GitlabGetError: If the server cannot perform the request
272276
"""
273-
obj = super(ProjectServiceManager, self).get(id, **kwargs)
277+
obj = cast(ProjectService, super(ProjectServiceManager, self).get(id, **kwargs))
274278
obj.id = id
275279
return obj
276280

277-
def update(self, id=None, new_data=None, **kwargs):
281+
def update(
282+
self,
283+
id: Optional[Union[str, int]] = None,
284+
new_data: Optional[Dict[str, Any]] = None,
285+
**kwargs: Any
286+
) -> Dict[str, Any]:
278287
"""Update an object on the server.
279288
280289
Args:
@@ -290,11 +299,12 @@ def update(self, id=None, new_data=None, **kwargs):
290299
GitlabUpdateError: If the server cannot perform the request
291300
"""
292301
new_data = new_data or {}
293-
super(ProjectServiceManager, self).update(id, new_data, **kwargs)
302+
result = super(ProjectServiceManager, self).update(id, new_data, **kwargs)
294303
self.id = id
304+
return result
295305

296306
@cli.register_custom_action("ProjectServiceManager")
297-
def available(self, **kwargs):
307+
def available(self, **kwargs: Any) -> List[str]:
298308
"""List the services known by python-gitlab.
299309
300310
Returns:

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ files = "."
1212
module = [
1313
"docs.*",
1414
"docs.ext.*",
15-
"gitlab.v4.objects.services",
1615
"gitlab.v4.objects.sidekiq",
1716
"tests.functional.*",
1817
"tests.functional.api.*",

0 commit comments

Comments
 (0)