rest: Add assertions for entries from supported methods.

Mypy considers that "Tuple[Any, ...]" is incompatible with
"Union[Tuple[Callable[..., HttpResponse], Set[str]], HttpResponse]".

handler, view_flags = entry is sufficient to suppress the error, but we
also add assertions for full measure.

Signed-off-by: Zixuan James Li <p359101898@gmail.com>
This commit is contained in:
Zixuan James Li
2022-08-15 14:58:15 -04:00
committed by Tim Abbott
parent c0287473b9
commit fcba35036b

View File

@@ -90,7 +90,10 @@ def get_target_view_function_or_response(
if method_to_use in supported_methods:
entry = supported_methods[method_to_use]
if isinstance(entry, tuple):
return entry
handler, view_flags = entry
assert callable(handler)
assert isinstance(view_flags, set)
return handler, view_flags
return supported_methods[method_to_use], set()
return json_method_not_allowed(list(supported_methods.keys()))