summaryrefslogtreecommitdiff
path: root/gitlab/v4/objects/keys.py
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2021-11-06 20:51:04 -0700
committerJohn L. Villalovos <john@sodarock.com>2021-11-07 12:35:23 -0800
commit8b75a7712dd1665d4b3eabb0c4594e80ab5e5308 (patch)
tree3f1b9a0574430272bc5e7ede26f77a235b789c4b /gitlab/v4/objects/keys.py
parentf3688dcf2dea33f5e17e456f86f8f50ff9312deb (diff)
downloadgitlab-8b75a7712dd1665d4b3eabb0c4594e80ab5e5308.tar.gz
chore: add type-hints to multiple files in gitlab/v4/objects/
Add and/or check type-hints for the following files gitlab.v4.objects.access_requests gitlab.v4.objects.applications gitlab.v4.objects.broadcast_messages gitlab.v4.objects.deployments gitlab.v4.objects.keys gitlab.v4.objects.merge_trains gitlab.v4.objects.namespaces gitlab.v4.objects.pages gitlab.v4.objects.personal_access_tokens gitlab.v4.objects.project_access_tokens gitlab.v4.objects.tags gitlab.v4.objects.templates gitlab.v4.objects.triggers Add a 'get' method with the correct type for Managers derived from GetMixin.
Diffstat (limited to 'gitlab/v4/objects/keys.py')
-rw-r--r--gitlab/v4/objects/keys.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/gitlab/v4/objects/keys.py b/gitlab/v4/objects/keys.py
index 7f8fa0e..46f6894 100644
--- a/gitlab/v4/objects/keys.py
+++ b/gitlab/v4/objects/keys.py
@@ -1,3 +1,5 @@
+from typing import Any, cast, Optional, TYPE_CHECKING, Union
+
from gitlab.base import RESTManager, RESTObject
from gitlab.mixins import GetMixin
@@ -15,12 +17,18 @@ class KeyManager(GetMixin, RESTManager):
_path = "/keys"
_obj_cls = Key
- def get(self, id=None, **kwargs):
+ def get(
+ self, id: Optional[Union[int, str]] = None, lazy: bool = False, **kwargs: Any
+ ) -> Key:
if id is not None:
- return super(KeyManager, self).get(id, **kwargs)
+ return cast(Key, super(KeyManager, self).get(id, lazy=lazy, **kwargs))
if "fingerprint" not in kwargs:
raise AttributeError("Missing attribute: id or fingerprint")
+ if TYPE_CHECKING:
+ assert self.path is not None
server_data = self.gitlab.http_get(self.path, **kwargs)
- return self._obj_cls(self, server_data)
+ if TYPE_CHECKING:
+ assert isinstance(server_data, dict)
+ return cast(Key, self._obj_cls(self, server_data))