Skip to content

Commit 8da0b75

Browse files
chore: add type-hints to gitlab/v4/objects/services.py
1 parent 00d7b20 commit 8da0b75

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
@@ -14,7 +14,6 @@ module = [
1414
"docs.ext.*",
1515
"gitlab.v4.objects.files",
1616
"gitlab.v4.objects.labels",
17-
"gitlab.v4.objects.services",
1817
"gitlab.v4.objects.sidekiq",
1918
"tests.functional.*",
2019
"tests.functional.api.*",

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy