diff options
author | Nejc Habjan <nejc.habjan@siemens.com> | 2022-07-29 10:36:00 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-29 10:36:00 +0200 |
commit | b8be32ae17fb59c5df080a9f7948fdff34b7d421 (patch) | |
tree | 9bbea7b42be567178e2251939f5efe5069abfce5 /gitlab/cli.py | |
parent | 1b7cd31dc9a4a15623ac168eaa355422634e2876 (diff) | |
parent | 76ec4b481fa931ea36a195ac474812c11babef7b (diff) | |
download | gitlab-b8be32ae17fb59c5df080a9f7948fdff34b7d421.tar.gz |
Merge pull request #2157 from python-gitlab/jlvillal/mypy_step_by_step
chore: enable mypy check `warn_return_any`
Diffstat (limited to 'gitlab/cli.py')
-rw-r--r-- | gitlab/cli.py | 20 |
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: |