mirror of
https://github.com/home-assistant/core.git
synced 2025-04-25 01:38:02 +00:00
Add QNAP QSW to strict typing (#71603)
This commit is contained in:
parent
b9b83c05e9
commit
d8e4f6d6e6
@ -175,6 +175,7 @@ homeassistant.components.powerwall.*
|
||||
homeassistant.components.proximity.*
|
||||
homeassistant.components.pvoutput.*
|
||||
homeassistant.components.pure_energie.*
|
||||
homeassistant.components.qnap_qsw.*
|
||||
homeassistant.components.rainmachine.*
|
||||
homeassistant.components.rdw.*
|
||||
homeassistant.components.recollect_waste.*
|
||||
|
@ -3,6 +3,7 @@ from __future__ import annotations
|
||||
|
||||
from datetime import timedelta
|
||||
import logging
|
||||
from typing import Any, cast
|
||||
|
||||
from aioqsw.exceptions import QswError
|
||||
from aioqsw.localapi import QnapQswApi
|
||||
@ -18,7 +19,7 @@ SCAN_INTERVAL = timedelta(seconds=60)
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class QswUpdateCoordinator(DataUpdateCoordinator):
|
||||
class QswUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]):
|
||||
"""Class to manage fetching data from the QNAP QSW device."""
|
||||
|
||||
def __init__(self, hass: HomeAssistant, qsw: QnapQswApi) -> None:
|
||||
@ -30,13 +31,14 @@ class QswUpdateCoordinator(DataUpdateCoordinator):
|
||||
_LOGGER,
|
||||
name=DOMAIN,
|
||||
update_interval=SCAN_INTERVAL,
|
||||
update_method=self._async_update,
|
||||
)
|
||||
|
||||
async def _async_update_data(self):
|
||||
async def _async_update(self) -> dict[str, Any]:
|
||||
"""Update data via library."""
|
||||
async with async_timeout.timeout(QSW_TIMEOUT_SEC):
|
||||
try:
|
||||
await self.qsw.update()
|
||||
except QswError as error:
|
||||
raise UpdateFailed(error) from error
|
||||
return self.qsw.data()
|
||||
return cast(dict[str, Any], self.qsw.data())
|
||||
|
11
mypy.ini
11
mypy.ini
@ -1688,6 +1688,17 @@ no_implicit_optional = true
|
||||
warn_return_any = true
|
||||
warn_unreachable = true
|
||||
|
||||
[mypy-homeassistant.components.qnap_qsw.*]
|
||||
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.rainmachine.*]
|
||||
check_untyped_defs = true
|
||||
disallow_incomplete_defs = true
|
||||
|
Loading…
x
Reference in New Issue
Block a user