diff --git a/homeassistant/components/litterrobot/entity.py b/homeassistant/components/litterrobot/entity.py index 2c4ed37f955..51b88bb4f79 100644 --- a/homeassistant/components/litterrobot/entity.py +++ b/homeassistant/components/litterrobot/entity.py @@ -9,7 +9,7 @@ from typing import Any from pylitterbot import Robot from pylitterbot.exceptions import InvalidCommandException -from homeassistant.core import callback +from homeassistant.core import CALLBACK_TYPE, callback from homeassistant.helpers.entity import DeviceInfo, EntityCategory from homeassistant.helpers.event import async_call_later from homeassistant.helpers.update_coordinator import CoordinatorEntity @@ -60,7 +60,7 @@ class LitterRobotControlEntity(LitterRobotEntity): def __init__(self, robot: Robot, entity_type: str, hub: LitterRobotHub) -> None: """Init a Litter-Robot control entity.""" super().__init__(robot=robot, entity_type=entity_type, hub=hub) - self._refresh_callback = None + self._refresh_callback: CALLBACK_TYPE | None = None async def perform_action_and_refresh( self, action: MethodType, *args: Any, **kwargs: Any @@ -99,8 +99,11 @@ class LitterRobotControlEntity(LitterRobotEntity): self._refresh_callback = None @staticmethod - def parse_time_at_default_timezone(time_str: str) -> time | None: + def parse_time_at_default_timezone(time_str: str | None) -> time | None: """Parse a time string and add default timezone.""" + if time_str is None: + return None + if (parsed_time := dt_util.parse_time(time_str)) is None: return None @@ -127,7 +130,7 @@ class LitterRobotConfigEntity(LitterRobotControlEntity): async def perform_action_and_assume_state( self, action: MethodType, assumed_state: Any - ) -> bool: + ) -> None: """Perform an action and assume the state passed in if call is successful.""" if await self.perform_action_and_refresh(action, assumed_state): self._assumed_state = assumed_state diff --git a/homeassistant/components/litterrobot/hub.py b/homeassistant/components/litterrobot/hub.py index 3aa86dcc93a..49fba822a6f 100644 --- a/homeassistant/components/litterrobot/hub.py +++ b/homeassistant/components/litterrobot/hub.py @@ -1,4 +1,7 @@ """A wrapper 'hub' for the Litter-Robot API.""" +from __future__ import annotations + +from collections.abc import Mapping from datetime import timedelta import logging @@ -19,10 +22,11 @@ UPDATE_INTERVAL_SECONDS = 20 class LitterRobotHub: """A Litter-Robot hub wrapper class.""" - def __init__(self, hass: HomeAssistant, data: dict) -> None: + account: Account + + def __init__(self, hass: HomeAssistant, data: Mapping) -> None: """Initialize the Litter-Robot hub.""" self._data = data - self.account = None self.logged_in = False async def _async_update_data() -> bool: @@ -40,7 +44,6 @@ class LitterRobotHub: async def login(self, load_robots: bool = False) -> None: """Login to Litter-Robot.""" - self.logged_in = False self.account = Account() try: await self.account.connect( @@ -48,8 +51,7 @@ class LitterRobotHub: password=self._data[CONF_PASSWORD], load_robots=load_robots, ) - self.logged_in = True - return self.logged_in + return except LitterRobotLoginException as ex: _LOGGER.error("Invalid credentials") raise ex diff --git a/mypy.ini b/mypy.ini index 95e2090f061..c72dfbee1bd 100644 --- a/mypy.ini +++ b/mypy.ini @@ -2420,30 +2420,6 @@ ignore_errors = true [mypy-homeassistant.components.kostal_plenticore.switch] ignore_errors = true -[mypy-homeassistant.components.litterrobot] -ignore_errors = true - -[mypy-homeassistant.components.litterrobot.button] -ignore_errors = true - -[mypy-homeassistant.components.litterrobot.entity] -ignore_errors = true - -[mypy-homeassistant.components.litterrobot.hub] -ignore_errors = true - -[mypy-homeassistant.components.litterrobot.select] -ignore_errors = true - -[mypy-homeassistant.components.litterrobot.sensor] -ignore_errors = true - -[mypy-homeassistant.components.litterrobot.switch] -ignore_errors = true - -[mypy-homeassistant.components.litterrobot.vacuum] -ignore_errors = true - [mypy-homeassistant.components.lovelace] ignore_errors = true diff --git a/script/hassfest/mypy_config.py b/script/hassfest/mypy_config.py index 99104702f26..53468caa29d 100644 --- a/script/hassfest/mypy_config.py +++ b/script/hassfest/mypy_config.py @@ -97,14 +97,6 @@ IGNORED_MODULES: Final[list[str]] = [ "homeassistant.components.kostal_plenticore.select", "homeassistant.components.kostal_plenticore.sensor", "homeassistant.components.kostal_plenticore.switch", - "homeassistant.components.litterrobot", - "homeassistant.components.litterrobot.button", - "homeassistant.components.litterrobot.entity", - "homeassistant.components.litterrobot.hub", - "homeassistant.components.litterrobot.select", - "homeassistant.components.litterrobot.sensor", - "homeassistant.components.litterrobot.switch", - "homeassistant.components.litterrobot.vacuum", "homeassistant.components.lovelace", "homeassistant.components.lovelace.dashboard", "homeassistant.components.lovelace.resources",