Skip to content

Commit 13243b7

Browse files
chore: add type-hints to gitlab/v4/objects/geo_nodes.py
1 parent d4adf8d commit 13243b7

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

gitlab/v4/objects/geo_nodes.py

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import Any, cast, Dict, List, TYPE_CHECKING, Union
2+
13
from gitlab import cli
24
from gitlab import exceptions as exc
35
from gitlab.base import RequiredOptional, RESTManager, RESTObject
@@ -18,7 +20,7 @@
1820
class GeoNode(SaveMixin, ObjectDeleteMixin, RESTObject):
1921
@cli.register_custom_action("GeoNode")
2022
@exc.on_http_error(exc.GitlabRepairError)
21-
def repair(self, **kwargs):
23+
def repair(self, **kwargs: Any) -> None:
2224
"""Repair the OAuth authentication of the geo node.
2325
2426
Args:
@@ -30,11 +32,13 @@ def repair(self, **kwargs):
3032
"""
3133
path = f"/geo_nodes/{self.get_id()}/repair"
3234
server_data = self.manager.gitlab.http_post(path, **kwargs)
35+
if TYPE_CHECKING:
36+
assert isinstance(server_data, dict)
3337
self._update_attrs(server_data)
3438

3539
@cli.register_custom_action("GeoNode")
3640
@exc.on_http_error(exc.GitlabGetError)
37-
def status(self, **kwargs):
41+
def status(self, **kwargs: Any) -> Dict[str, Any]:
3842
"""Get the status of the geo node.
3943
4044
Args:
@@ -48,7 +52,10 @@ def status(self, **kwargs):
4852
dict: The status of the geo node
4953
"""
5054
path = f"/geo_nodes/{self.get_id()}/status"
51-
return self.manager.gitlab.http_get(path, **kwargs)
55+
result = self.manager.gitlab.http_get(path, **kwargs)
56+
if TYPE_CHECKING:
57+
assert isinstance(result, dict)
58+
return result
5259

5360

5461
class GeoNodeManager(RetrieveMixin, UpdateMixin, DeleteMixin, RESTManager):
@@ -58,9 +65,12 @@ class GeoNodeManager(RetrieveMixin, UpdateMixin, DeleteMixin, RESTManager):
5865
optional=("enabled", "url", "files_max_capacity", "repos_max_capacity"),
5966
)
6067

68+
def get(self, id: Union[str, int], lazy: bool = False, **kwargs: Any) -> GeoNode:
69+
return cast(GeoNode, super().get(id=id, lazy=lazy, **kwargs))
70+
6171
@cli.register_custom_action("GeoNodeManager")
6272
@exc.on_http_error(exc.GitlabGetError)
63-
def status(self, **kwargs):
73+
def status(self, **kwargs: Any) -> List[Dict[str, Any]]:
6474
"""Get the status of all the geo nodes.
6575
6676
Args:
@@ -73,11 +83,14 @@ def status(self, **kwargs):
7383
Returns:
7484
list: The status of all the geo nodes
7585
"""
76-
return self.gitlab.http_list("/geo_nodes/status", **kwargs)
86+
result = self.gitlab.http_list("/geo_nodes/status", **kwargs)
87+
if TYPE_CHECKING:
88+
assert isinstance(result, list)
89+
return result
7790

7891
@cli.register_custom_action("GeoNodeManager")
7992
@exc.on_http_error(exc.GitlabGetError)
80-
def current_failures(self, **kwargs):
93+
def current_failures(self, **kwargs: Any) -> List[Dict[str, Any]]:
8194
"""Get the list of failures on the current geo node.
8295
8396
Args:
@@ -90,4 +103,7 @@ def current_failures(self, **kwargs):
90103
Returns:
91104
list: The list of failures
92105
"""
93-
return self.gitlab.http_list("/geo_nodes/current/failures", **kwargs)
106+
result = self.gitlab.http_list("/geo_nodes/current/failures", **kwargs)
107+
if TYPE_CHECKING:
108+
assert isinstance(result, list)
109+
return result

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ module = [
1313
"docs.*",
1414
"docs.ext.*",
1515
"gitlab.v4.objects.files",
16-
"gitlab.v4.objects.geo_nodes",
1716
"gitlab.v4.objects.issues",
1817
"gitlab.v4.objects.jobs",
1918
"gitlab.v4.objects.labels",

0 commit comments

Comments
 (0)