fix(api): don't return list for runtime tools

Use Response object instead.

Enforce no GET endpoints return lists.

Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
This commit is contained in:
Ihar Hrachyshka 2025-03-18 18:22:48 -04:00
parent b440a1dc42
commit 508381a81d
13 changed files with 167 additions and 105 deletions

View file

@ -135,6 +135,17 @@ def _validate_api_method_return_type(method) -> str | None:
return "returns Optional type"
def _validate_api_method_doesnt_return_list(method) -> str | None:
hints = get_type_hints(method)
if 'return' not in hints:
return "has no return type annotation"
return_type = hints['return']
if get_origin(return_type) is list:
return "returns a list"
def _validate_api_delete_method_returns_none(method) -> str | None:
hints = get_type_hints(method)
@ -167,6 +178,7 @@ _VALIDATORS = {
"GET": [
_validate_api_method_return_type,
_validate_list_parameters_contain_data,
_validate_api_method_doesnt_return_list,
],
"DELETE": [
_validate_api_delete_method_returns_none,