Skip to content

Commit 2e88cd4

Browse files
wip: trying to find code that doesn't return a dict
1 parent badc916 commit 2e88cd4

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
- name: Run tests
7474
env:
7575
TOXENV: ${{ matrix.toxenv }}
76-
run: tox -- --override-ini='log_cli=True'
76+
run: tox -- -vv --override-ini='log_cli=True'
7777
- name: Upload codecov coverage
7878
uses: codecov/codecov-action@v3
7979
with:

gitlab/exceptions.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717

1818
import functools
19+
import inspect
1920
from typing import Any, Callable, cast, Optional, Type, TYPE_CHECKING, TypeVar, Union
2021

2122

@@ -331,10 +332,23 @@ def wrap(f: __F) -> __F:
331332
@functools.wraps(f)
332333
def wrapped_f(*args: Any, **kwargs: Any) -> Any:
333334
try:
334-
return f(*args, **kwargs)
335+
result = f(*args, **kwargs)
335336
except GitlabHttpError as e:
336337
raise error(e.error_message, e.response_code, e.response_body) from e
337338

339+
annotations = inspect.get_annotations(f)
340+
return_type = annotations.get("return", "")
341+
if (
342+
"typing.Union[typing.Dict[str, typing.Any], "
343+
"typing.List[typing.Any], requests.models.Response]"
344+
) in str(return_type):
345+
if not isinstance(result, dict):
346+
print(f, annotations)
347+
print(f"str: {str(return_type)!r}")
348+
print(f"{type(result)} {result!r}")
349+
assert 0
350+
return result
351+
338352
return cast(__F, wrapped_f)
339353

340354
return wrap

0 commit comments

Comments
 (0)