summaryrefslogtreecommitdiff
path: root/gitlab/base.py
diff options
context:
space:
mode:
authorJohn L. Villalovos <john@sodarock.com>2022-07-28 21:39:22 -0700
committerJohn L. Villalovos <john@sodarock.com>2022-07-28 21:39:22 -0700
commit76ec4b481fa931ea36a195ac474812c11babef7b (patch)
tree23ddb54416eea1971f5b7aaa6fc3e71e941d503b /gitlab/base.py
parent8ba97aa459420ec5ae824d9299d6564656841559 (diff)
downloadgitlab-76ec4b481fa931ea36a195ac474812c11babef7b.tar.gz
chore: enable mypy check `warn_return_any`
Update code so that the `warn_return_any` check passes.
Diffstat (limited to 'gitlab/base.py')
-rw-r--r--gitlab/base.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/gitlab/base.py b/gitlab/base.py
index e813fcd..c2df65a 100644
--- a/gitlab/base.py
+++ b/gitlab/base.py
@@ -21,7 +21,7 @@ import json
import pprint
import textwrap
from types import ModuleType
-from typing import Any, Dict, Iterable, Optional, Type, Union
+from typing import Any, Dict, Iterable, Optional, Type, TYPE_CHECKING, Union
import gitlab
from gitlab import types as g_types
@@ -245,14 +245,20 @@ class RESTObject:
"""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)
+ id_val = getattr(self, self._id_attr)
+ if TYPE_CHECKING:
+ assert id_val is None or isinstance(id_val, (int, str))
+ return id_val
@property
def _repr_value(self) -> Optional[str]:
"""Safely returns the human-readable resource name if present."""
if self._repr_attr is None or not hasattr(self, self._repr_attr):
return None
- return getattr(self, self._repr_attr)
+ repr_val = getattr(self, self._repr_attr)
+ if TYPE_CHECKING:
+ assert isinstance(repr_val, str)
+ return repr_val
@property
def encoded_id(self) -> Optional[Union[int, str]]: