diff --git a/.strict-typing b/.strict-typing index 9ab2d535f0fac2..a7758750d5e9e4 100644 --- a/.strict-typing +++ b/.strict-typing @@ -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.* diff --git a/homeassistant/components/api/__init__.py b/homeassistant/components/api/__init__.py index 8a5e1f0b0e0d15..048837dae68042 100644 --- a/homeassistant/components/api/__init__.py +++ b/homeassistant/components/api/__init__.py @@ -433,7 +433,7 @@ def get(self, request: web.Request) -> web.Response: @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 @@ async def post(self, request: web.Request) -> web.Response: 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 diff --git a/mypy.ini b/mypy.ini index bfeaa28ef04130..163be50e6eb0c3 100644 --- a/mypy.ini +++ b/mypy.ini @@ -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