Add strict typing to Tractive integration (#56948)
* Strict typing * Add few missing types * Run hassfest * Fix mypy errors * Use List instead of list
This commit is contained in:
parent
1aeab65f56
commit
f3c76fb859
10 changed files with 166 additions and 134 deletions
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
|
||||
from dataclasses import dataclass
|
||||
import logging
|
||||
from typing import Any, Literal
|
||||
from typing import Any, Final, Literal, cast
|
||||
|
||||
from aiotractive.exceptions import TractiveError
|
||||
|
||||
|
@ -26,7 +26,7 @@ from .const import (
|
|||
)
|
||||
from .entity import TractiveEntity
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
_LOGGER: Final = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -43,7 +43,7 @@ class TractiveSwitchEntityDescription(
|
|||
"""Class describing Tractive switch entities."""
|
||||
|
||||
|
||||
SWITCH_TYPES: tuple[TractiveSwitchEntityDescription, ...] = (
|
||||
SWITCH_TYPES: Final[tuple[TractiveSwitchEntityDescription, ...]] = (
|
||||
TractiveSwitchEntityDescription(
|
||||
key=ATTR_BUZZER,
|
||||
name="Tracker Buzzer",
|
||||
|
@ -162,12 +162,14 @@ class TractiveSwitch(TractiveEntity, SwitchEntity):
|
|||
|
||||
async def async_set_buzzer(self, active: bool) -> dict[str, Any]:
|
||||
"""Set the buzzer on/off."""
|
||||
return await self._tracker.set_buzzer_active(active)
|
||||
return cast(dict[str, Any], await self._tracker.set_buzzer_active(active))
|
||||
|
||||
async def async_set_led(self, active: bool) -> dict[str, Any]:
|
||||
"""Set the LED on/off."""
|
||||
return await self._tracker.set_led_active(active)
|
||||
return cast(dict[str, Any], await self._tracker.set_led_active(active))
|
||||
|
||||
async def async_set_live_tracking(self, active: bool) -> dict[str, Any]:
|
||||
"""Set the live tracking on/off."""
|
||||
return await self._tracker.set_live_tracking_active(active)
|
||||
return cast(
|
||||
dict[str, Any], await self._tracker.set_live_tracking_active(active)
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue