chore: require data field for all List*Response models

No violators are currently in-tree. This is just hardening the api specs
for future consistency.

Signed-off-by: Ihar Hrachyshka <ihar.hrachyshka@gmail.com>
This commit is contained in:
Ihar Hrachyshka 2025-03-26 17:33:22 -04:00
parent cb2a9784ab
commit 227fe636f4

View file

@ -146,9 +146,27 @@ def _validate_api_delete_method_returns_none(method) -> str | None:
return "does not return None"
def _validate_list_parameters_contain_data(method) -> str | None:
hints = get_type_hints(method)
if 'return' not in hints:
return "has no return type annotation"
return_type = hints['return']
if not inspect.isclass(return_type):
return
if not return_type.__name__.startswith('List'):
return
if 'data' not in return_type.model_fields:
return "does not have data attribute"
_VALIDATORS = {
"GET": [
_validate_api_method_return_type,
_validate_list_parameters_contain_data,
],
"DELETE": [
_validate_api_delete_method_returns_none,