mirror of
https://github.com/meta-llama/llama-stack.git
synced 2025-12-31 15:03:54 +00:00
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:
parent
b440a1dc42
commit
508381a81d
13 changed files with 167 additions and 105 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue