Use literal string interpolation in core (f-strings) (#26166)

This commit is contained in:
Franck Nijhof authored and Paulus Schoutsen committed 2019-08-23 09:53:33 -07:00
1 parent 1efa29d6ff
commit decf13b948
67 files changed
+180 -246

No files matched your search

+3 -3
View File
@@ -138,7 +138,7 @@ class APIEventStream(HomeAssistantView):
if payload is stop_obj:
break
msg = "data: {}\n\n".format(payload)
msg = f"data: {payload}\n\n"
_LOGGER.debug("STREAM %s WRITING %s", id(stop_obj), msg.strip())
await response.write(msg.encode("UTF-8"))
except asyncio.TimeoutError:
@@ -316,7 +316,7 @@ class APIEventView(HomeAssistantView):
event_type, event_data, ha.EventOrigin.remote, self.context(request)
)
return self.json_message("Event {} fired.".format(event_type))
return self.json_message(f"Event {event_type} fired.")
class APIServicesView(HomeAssistantView):
@@ -388,7 +388,7 @@ class APITemplateView(HomeAssistantView):
return tpl.async_render(data.get("variables"))
except (ValueError, TemplateError) as ex:
return self.json_message(
"Error rendering template: {}".format(ex), HTTP_BAD_REQUEST
f"Error rendering template: {ex}", HTTP_BAD_REQUEST
)