summaryrefslogtreecommitdiff
path: root/gitlab/base.py
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2022-01-14 15:33:46 -0800
committerJohn L. Villalovos <john@sodarock.com>2022-01-14 15:33:46 -0800
commit0c3a1d163895f660340a6c2b2f196ad996542518 (patch)
treecef48e066620e4802711ad38f2b7381d3825c93e /gitlab/base.py
parenta1dbe86c20b205ce135a7592d5c551e67adfb929 (diff)
downloadgitlab-0c3a1d163895f660340a6c2b2f196ad996542518.tar.gz
chore: create return type-hints for `get_id()` & `encoded_id`
Create return type-hints for `RESTObject.get_id()` and `RESTObject.encoded_id`. Previously was saying they return Any. Be more precise in saying they can return either: None, str, or int.
Diffstat (limited to 'gitlab/base.py')
-rw-r--r--gitlab/base.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/gitlab/base.py b/gitlab/base.py
index 0706ffb..dc7a004 100644
--- a/gitlab/base.py
+++ b/gitlab/base.py
@@ -19,7 +19,7 @@ import importlib
import pprint
import textwrap
from types import ModuleType
-from typing import Any, Dict, Iterable, NamedTuple, Optional, Tuple, Type
+from typing import Any, Dict, Iterable, NamedTuple, Optional, Tuple, Type, Union
import gitlab
from gitlab import types as g_types
@@ -211,14 +211,14 @@ class RESTObject(object):
self.__dict__["_updated_attrs"] = {}
self.__dict__["_attrs"] = new_attrs
- def get_id(self) -> Any:
+ def get_id(self) -> Optional[Union[int, str]]:
"""Returns the id of the resource."""
if self._id_attr is None or not hasattr(self, self._id_attr):
return None
return getattr(self, self._id_attr)
@property
- def encoded_id(self) -> Any:
+ def encoded_id(self) -> Optional[Union[int, str]]:
"""Ensure that the ID is url-encoded so that it can be safely used in a URL
path"""
obj_id = self.get_id()