Enable strict typing for api (#108363)

This commit is contained in:
Marc Mueller 2024-01-19 13:33:20 +01:00 committed by GitHub
parent 7e0e306c1f
commit 15bd31e8d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 13 additions and 2 deletions

View File

@ -77,6 +77,7 @@ homeassistant.components.anova.*
homeassistant.components.anthemav.*
homeassistant.components.apache_kafka.*
homeassistant.components.apcupsd.*
homeassistant.components.api.*
homeassistant.components.apprise.*
homeassistant.components.aprs.*
homeassistant.components.aqualogic.*

View File

@ -433,7 +433,7 @@ class APIComponentsView(HomeAssistantView):
@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 template.Template(template_str, hass)
@ -450,7 +450,7 @@ class APITemplateView(HomeAssistantView):
try:
data = await request.json()
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:
return self.json_message(
f"Error rendering template: {ex}", HTTPStatus.BAD_REQUEST

View File

@ -530,6 +530,16 @@ disallow_untyped_defs = true
warn_return_any = 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.*]
check_untyped_defs = true
disallow_incomplete_defs = true