mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 21:27:38 +00:00
Enable strict typing for api (#108363)
This commit is contained in:
parent
7e0e306c1f
commit
15bd31e8d8
@ -77,6 +77,7 @@ homeassistant.components.anova.*
|
|||||||
homeassistant.components.anthemav.*
|
homeassistant.components.anthemav.*
|
||||||
homeassistant.components.apache_kafka.*
|
homeassistant.components.apache_kafka.*
|
||||||
homeassistant.components.apcupsd.*
|
homeassistant.components.apcupsd.*
|
||||||
|
homeassistant.components.api.*
|
||||||
homeassistant.components.apprise.*
|
homeassistant.components.apprise.*
|
||||||
homeassistant.components.aprs.*
|
homeassistant.components.aprs.*
|
||||||
homeassistant.components.aqualogic.*
|
homeassistant.components.aqualogic.*
|
||||||
|
@ -433,7 +433,7 @@ class APIComponentsView(HomeAssistantView):
|
|||||||
|
|
||||||
|
|
||||||
@lru_cache
|
@lru_cache
|
||||||
def _cached_template(template_str: str, hass: ha.HomeAssistant) -> template.Template:
|
def _cached_template(template_str: str, hass: HomeAssistant) -> template.Template:
|
||||||
"""Return a cached template."""
|
"""Return a cached template."""
|
||||||
return template.Template(template_str, hass)
|
return template.Template(template_str, hass)
|
||||||
|
|
||||||
@ -450,7 +450,7 @@ class APITemplateView(HomeAssistantView):
|
|||||||
try:
|
try:
|
||||||
data = await request.json()
|
data = await request.json()
|
||||||
tpl = _cached_template(data["template"], request.app["hass"])
|
tpl = _cached_template(data["template"], request.app["hass"])
|
||||||
return tpl.async_render(variables=data.get("variables"), parse_result=False)
|
return tpl.async_render(variables=data.get("variables"), parse_result=False) # type: ignore[no-any-return]
|
||||||
except (ValueError, TemplateError) as ex:
|
except (ValueError, TemplateError) as ex:
|
||||||
return self.json_message(
|
return self.json_message(
|
||||||
f"Error rendering template: {ex}", HTTPStatus.BAD_REQUEST
|
f"Error rendering template: {ex}", HTTPStatus.BAD_REQUEST
|
||||||
|
10
mypy.ini
10
mypy.ini
@ -530,6 +530,16 @@ disallow_untyped_defs = true
|
|||||||
warn_return_any = true
|
warn_return_any = true
|
||||||
warn_unreachable = true
|
warn_unreachable = true
|
||||||
|
|
||||||
|
[mypy-homeassistant.components.api.*]
|
||||||
|
check_untyped_defs = true
|
||||||
|
disallow_incomplete_defs = true
|
||||||
|
disallow_subclassing_any = true
|
||||||
|
disallow_untyped_calls = true
|
||||||
|
disallow_untyped_decorators = true
|
||||||
|
disallow_untyped_defs = true
|
||||||
|
warn_return_any = true
|
||||||
|
warn_unreachable = true
|
||||||
|
|
||||||
[mypy-homeassistant.components.apprise.*]
|
[mypy-homeassistant.components.apprise.*]
|
||||||
check_untyped_defs = true
|
check_untyped_defs = true
|
||||||
disallow_incomplete_defs = true
|
disallow_incomplete_defs = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user