From d52ac8fd744e23cc12e69475c3729f6849c449fc Mon Sep 17 00:00:00 2001 From: Matthias Bisping Date: Mon, 20 Jun 2022 16:34:16 +0200 Subject: [PATCH] response formatter selects map fn or fn by type of message --- pyinfra/visitor/response_formatter/formatter.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pyinfra/visitor/response_formatter/formatter.py b/pyinfra/visitor/response_formatter/formatter.py index 589defc..ebb4832 100644 --- a/pyinfra/visitor/response_formatter/formatter.py +++ b/pyinfra/visitor/response_formatter/formatter.py @@ -1,9 +1,13 @@ import abc +from funcy import identity + +from pyinfra.utils.func import lift + class ResponseFormatter(abc.ABC): def __call__(self, message): - return map(self.format, message) + return (identity if isinstance(message, dict) else lift)(self.format)(message) @abc.abstractmethod def format(self, message):