From 7271d4e603ee386eddfea257fb791399996536a2 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Fri, 6 May 2022 13:48:47 -0400 Subject: [PATCH] pybind/mgr: extend return types valid for Responder wrapped functions One wonders why this wasn't found by the test code, but oh well. Signed-off-by: John Mulligan (cherry picked from commit 370901a4e66f5d5a03c18cfd3808e7026d291385) --- src/pybind/mgr/object_format.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/object_format.py b/src/pybind/mgr/object_format.py index ab3e0c70762..d4c04fd9144 100644 --- a/src/pybind/mgr/object_format.py +++ b/src/pybind/mgr/object_format.py @@ -190,12 +190,6 @@ class Format(str, enum.Enum): SimpleData = Any -ObjectResponseFuncType = Union[ - Callable[..., Dict[Any, Any]], - Callable[..., List[Any]], -] - - class SimpleDataProvider(Protocol): def to_simplified(self) -> SimpleData: """Return a simplified representation of the current object. @@ -443,6 +437,16 @@ class ErrorResponse(ErrorResponseBase): return err +ObjectResponseFuncType = Union[ + Callable[..., Dict[Any, Any]], + Callable[..., List[Any]], + Callable[..., SimpleDataProvider], + Callable[..., JSONDataProvider], + Callable[..., YAMLDataProvider], + Callable[..., ReturnValueProvider], +] + + def _get_requested_format(f: ObjectResponseFuncType, kw: Dict[str, Any]) -> str: # todo: leave 'format' in kw dict iff its part of f's signature return kw.pop("format", None) -- 2.47.3