diff --git a/.strict-typing b/.strict-typing index a1353afb657..96b153306fd 100644 --- a/.strict-typing +++ b/.strict-typing @@ -251,6 +251,7 @@ homeassistant.components.ridwell.* homeassistant.components.rituals_perfume_genie.* homeassistant.components.roku.* homeassistant.components.rpi_power.* +homeassistant.components.rss_feed_template.* homeassistant.components.rtsp_to_webrtc.* homeassistant.components.ruuvi_gateway.* homeassistant.components.ruuvitag_ble.* diff --git a/homeassistant/components/rss_feed_template/__init__.py b/homeassistant/components/rss_feed_template/__init__.py index 4dcbf7fe048..27a67fd6640 100644 --- a/homeassistant/components/rss_feed_template/__init__.py +++ b/homeassistant/components/rss_feed_template/__init__.py @@ -1,4 +1,6 @@ """Support to export sensor values via RSS feed.""" +from __future__ import annotations + from html import escape from aiohttp import web @@ -7,6 +9,7 @@ import voluptuous as vol from homeassistant.components.http import HomeAssistantView from homeassistant.core import HomeAssistant import homeassistant.helpers.config_validation as cv +from homeassistant.helpers.template import Template from homeassistant.helpers.typing import ConfigType CONTENT_TYPE_XML = "text/xml" @@ -43,12 +46,13 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool: for (feeduri, feedconfig) in config[DOMAIN].items(): url = f"/api/rss_template/{feeduri}" - requires_auth = feedconfig.get("requires_api_password") + requires_auth: bool = feedconfig["requires_api_password"] + title: Template | None if (title := feedconfig.get("title")) is not None: title.hass = hass - items = feedconfig.get("items") + items: list[dict[str, Template]] = feedconfig["items"] for item in items: if "title" in item: item["title"].hass = hass @@ -64,20 +68,22 @@ def setup(hass: HomeAssistant, config: ConfigType) -> bool: class RssView(HomeAssistantView): """Export states and other values as RSS.""" - requires_auth = True - url = None name = "rss_template" - _title = None - _items = None - def __init__(self, url, requires_auth, title, items): + def __init__( + self, + url: str, + requires_auth: bool, + title: Template | None, + items: list[dict[str, Template]], + ) -> None: """Initialize the rss view.""" self.url = url self.requires_auth = requires_auth self._title = title self._items = items - async def get(self, request, entity_id=None): + async def get(self, request: web.Request) -> web.Response: """Generate the RSS view XML.""" response = '\n\n' diff --git a/mypy.ini b/mypy.ini index 9dee493bf28..08697386bd9 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2264,6 +2264,16 @@ disallow_untyped_defs = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.rss_feed_template.*] +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.rtsp_to_webrtc.*] check_untyped_defs = true disallow_incomplete_defs = true