mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 23:13:25 +00:00
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:
committed by
Tim Abbott
parent
c0287473b9
commit
fcba35036b
@@ -90,7 +90,10 @@ def get_target_view_function_or_response(
|
|||||||
if method_to_use in supported_methods:
|
if method_to_use in supported_methods:
|
||||||
entry = supported_methods[method_to_use]
|
entry = supported_methods[method_to_use]
|
||||||
if isinstance(entry, tuple):
|
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 supported_methods[method_to_use], set()
|
||||||
|
|
||||||
return json_method_not_allowed(list(supported_methods.keys()))
|
return json_method_not_allowed(list(supported_methods.keys()))
|
||||||
|
|||||||
Reference in New Issue
Block a user