Fix type issues [litterrobot] (#67092)

This commit is contained in:
Marc Mueller 2022-02-23 08:44:35 +01:00 committed by GitHub
parent fda3877852
commit 636d791b37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 41 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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",