Fix type issues [litterrobot] (#67092)
This commit is contained in:
parent
fda3877852
commit
636d791b37
4 changed files with 14 additions and 41 deletions
|
@ -9,7 +9,7 @@ from typing import Any
|
||||||
from pylitterbot import Robot
|
from pylitterbot import Robot
|
||||||
from pylitterbot.exceptions import InvalidCommandException
|
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.entity import DeviceInfo, EntityCategory
|
||||||
from homeassistant.helpers.event import async_call_later
|
from homeassistant.helpers.event import async_call_later
|
||||||
from homeassistant.helpers.update_coordinator import CoordinatorEntity
|
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:
|
def __init__(self, robot: Robot, entity_type: str, hub: LitterRobotHub) -> None:
|
||||||
"""Init a Litter-Robot control entity."""
|
"""Init a Litter-Robot control entity."""
|
||||||
super().__init__(robot=robot, entity_type=entity_type, hub=hub)
|
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(
|
async def perform_action_and_refresh(
|
||||||
self, action: MethodType, *args: Any, **kwargs: Any
|
self, action: MethodType, *args: Any, **kwargs: Any
|
||||||
|
@ -99,8 +99,11 @@ class LitterRobotControlEntity(LitterRobotEntity):
|
||||||
self._refresh_callback = None
|
self._refresh_callback = None
|
||||||
|
|
||||||
@staticmethod
|
@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."""
|
"""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:
|
if (parsed_time := dt_util.parse_time(time_str)) is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -127,7 +130,7 @@ class LitterRobotConfigEntity(LitterRobotControlEntity):
|
||||||
|
|
||||||
async def perform_action_and_assume_state(
|
async def perform_action_and_assume_state(
|
||||||
self, action: MethodType, assumed_state: Any
|
self, action: MethodType, assumed_state: Any
|
||||||
) -> bool:
|
) -> None:
|
||||||
"""Perform an action and assume the state passed in if call is successful."""
|
"""Perform an action and assume the state passed in if call is successful."""
|
||||||
if await self.perform_action_and_refresh(action, assumed_state):
|
if await self.perform_action_and_refresh(action, assumed_state):
|
||||||
self._assumed_state = assumed_state
|
self._assumed_state = assumed_state
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
"""A wrapper 'hub' for the Litter-Robot API."""
|
"""A wrapper 'hub' for the Litter-Robot API."""
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from collections.abc import Mapping
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
@ -19,10 +22,11 @@ UPDATE_INTERVAL_SECONDS = 20
|
||||||
class LitterRobotHub:
|
class LitterRobotHub:
|
||||||
"""A Litter-Robot hub wrapper class."""
|
"""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."""
|
"""Initialize the Litter-Robot hub."""
|
||||||
self._data = data
|
self._data = data
|
||||||
self.account = None
|
|
||||||
self.logged_in = False
|
self.logged_in = False
|
||||||
|
|
||||||
async def _async_update_data() -> bool:
|
async def _async_update_data() -> bool:
|
||||||
|
@ -40,7 +44,6 @@ class LitterRobotHub:
|
||||||
|
|
||||||
async def login(self, load_robots: bool = False) -> None:
|
async def login(self, load_robots: bool = False) -> None:
|
||||||
"""Login to Litter-Robot."""
|
"""Login to Litter-Robot."""
|
||||||
self.logged_in = False
|
|
||||||
self.account = Account()
|
self.account = Account()
|
||||||
try:
|
try:
|
||||||
await self.account.connect(
|
await self.account.connect(
|
||||||
|
@ -48,8 +51,7 @@ class LitterRobotHub:
|
||||||
password=self._data[CONF_PASSWORD],
|
password=self._data[CONF_PASSWORD],
|
||||||
load_robots=load_robots,
|
load_robots=load_robots,
|
||||||
)
|
)
|
||||||
self.logged_in = True
|
return
|
||||||
return self.logged_in
|
|
||||||
except LitterRobotLoginException as ex:
|
except LitterRobotLoginException as ex:
|
||||||
_LOGGER.error("Invalid credentials")
|
_LOGGER.error("Invalid credentials")
|
||||||
raise ex
|
raise ex
|
||||||
|
|
24
mypy.ini
24
mypy.ini
|
@ -2420,30 +2420,6 @@ ignore_errors = true
|
||||||
[mypy-homeassistant.components.kostal_plenticore.switch]
|
[mypy-homeassistant.components.kostal_plenticore.switch]
|
||||||
ignore_errors = true
|
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]
|
[mypy-homeassistant.components.lovelace]
|
||||||
ignore_errors = true
|
ignore_errors = true
|
||||||
|
|
||||||
|
|
|
@ -97,14 +97,6 @@ IGNORED_MODULES: Final[list[str]] = [
|
||||||
"homeassistant.components.kostal_plenticore.select",
|
"homeassistant.components.kostal_plenticore.select",
|
||||||
"homeassistant.components.kostal_plenticore.sensor",
|
"homeassistant.components.kostal_plenticore.sensor",
|
||||||
"homeassistant.components.kostal_plenticore.switch",
|
"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",
|
||||||
"homeassistant.components.lovelace.dashboard",
|
"homeassistant.components.lovelace.dashboard",
|
||||||
"homeassistant.components.lovelace.resources",
|
"homeassistant.components.lovelace.resources",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue