summaryrefslogtreecommitdiff
path: root/gitlab/cli.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/cli.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/cli.py')
-rw-r--r--gitlab/cli.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/gitlab/cli.py b/gitlab/cli.py
index fd519c3..294d6a8 100644
--- a/gitlab/cli.py
+++ b/gitlab/cli.py
@@ -23,7 +23,18 @@ import os
import re
import sys
from types import ModuleType
-from typing import Any, Callable, cast, Dict, Optional, Tuple, Type, TypeVar, Union
+from typing import (
+ Any,
+ Callable,
+ cast,
+ Dict,
+ Optional,
+ Tuple,
+ Type,
+ TYPE_CHECKING,
+ TypeVar,
+ Union,
+)
from requests.structures import CaseInsensitiveDict
@@ -113,8 +124,11 @@ def gitlab_resource_to_cls(
) -> Type[RESTObject]:
classes = CaseInsensitiveDict(namespace.__dict__)
lowercase_class = gitlab_resource.replace("-", "")
-
- return classes[lowercase_class]
+ class_type = classes[lowercase_class]
+ if TYPE_CHECKING:
+ assert isinstance(class_type, type)
+ assert issubclass(class_type, RESTObject)
+ return class_type
def cls_to_gitlab_resource(cls: RESTObject) -> str: