diff --git a/.strict-typing b/.strict-typing index 23b4ed76513..2ad7d0d1107 100644 --- a/.strict-typing +++ b/.strict-typing @@ -74,6 +74,7 @@ homeassistant.components.vacuum.* homeassistant.components.water_heater.* homeassistant.components.weather.* homeassistant.components.websocket_api.* +homeassistant.components.zodiac.* homeassistant.components.zeroconf.* homeassistant.components.zone.* homeassistant.components.zwave_js.* diff --git a/homeassistant/components/zodiac/__init__.py b/homeassistant/components/zodiac/__init__.py index d00cc560f22..c19b7a45ac2 100644 --- a/homeassistant/components/zodiac/__init__.py +++ b/homeassistant/components/zodiac/__init__.py @@ -3,6 +3,7 @@ import voluptuous as vol from homeassistant.core import HomeAssistant from homeassistant.helpers.discovery import async_load_platform +from homeassistant.helpers.typing import ConfigType from .const import DOMAIN @@ -12,7 +13,7 @@ CONFIG_SCHEMA = vol.Schema( ) -async def async_setup(hass: HomeAssistant, config: dict): +async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool: """Set up the zodiac component.""" hass.async_create_task(async_load_platform(hass, "sensor", DOMAIN, {}, config)) diff --git a/homeassistant/components/zodiac/sensor.py b/homeassistant/components/zodiac/sensor.py index 4c037a7aa02..80a4f782915 100644 --- a/homeassistant/components/zodiac/sensor.py +++ b/homeassistant/components/zodiac/sensor.py @@ -1,5 +1,10 @@ """Support for tracking the zodiac sign.""" +from __future__ import annotations + from homeassistant.components.sensor import SensorEntity +from homeassistant.core import HomeAssistant +from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType from homeassistant.util.dt import as_local, utcnow from .const import ( @@ -154,7 +159,12 @@ ZODIAC_ICONS = { } -async def async_setup_platform(hass, config, async_add_entities, discovery_info=None): +async def async_setup_platform( + hass: HomeAssistant, + config: ConfigType, + async_add_entities: AddEntitiesCallback, + discovery_info: DiscoveryInfoType | None = None, +) -> None: """Set up the Zodiac sensor platform.""" if discovery_info is None: return @@ -165,42 +175,42 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info= class ZodiacSensor(SensorEntity): """Representation of a Zodiac sensor.""" - def __init__(self): + def __init__(self) -> None: """Initialize the zodiac sensor.""" - self._attrs = None - self._state = None + self._attrs: dict[str, str] = {} + self._state: str = "" @property - def unique_id(self): + def unique_id(self) -> str: """Return a unique ID.""" return DOMAIN @property - def name(self): + def name(self) -> str: """Return the name of the entity.""" return "Zodiac" @property - def device_class(self): + def device_class(self) -> str: """Return the device class of the entity.""" return "zodiac__sign" @property - def state(self): + def state(self) -> str: """Return the state of the device.""" return self._state @property - def icon(self): - """Icon to use in the frontend, if any.""" + def icon(self) -> str | None: + """Icon to use in the frontend.""" return ZODIAC_ICONS.get(self._state) @property - def extra_state_attributes(self): + def extra_state_attributes(self) -> dict[str, str]: """Return the state attributes.""" return self._attrs - async def async_update(self): + async def async_update(self) -> None: """Get the time and updates the state.""" today = as_local(utcnow()).date() diff --git a/mypy.ini b/mypy.ini index bada042219a..c25dc4ec1f6 100644 --- a/mypy.ini +++ b/mypy.ini @@ -825,6 +825,17 @@ no_implicit_optional = true warn_return_any = true warn_unreachable = true +[mypy-homeassistant.components.zodiac.*] +check_untyped_defs = true +disallow_incomplete_defs = true +disallow_subclassing_any = true +disallow_untyped_calls = true +disallow_untyped_decorators = true +disallow_untyped_defs = true +no_implicit_optional = true +warn_return_any = true +warn_unreachable = true + [mypy-homeassistant.components.zeroconf.*] check_untyped_defs = true disallow_incomplete_defs = true