Use Final type only when needed in Tractive (#57000)
This commit is contained in:
parent
1488019cd9
commit
946a265c9e
6 changed files with 27 additions and 28 deletions
|
@ -4,7 +4,7 @@ from __future__ import annotations
|
|||
import asyncio
|
||||
from dataclasses import dataclass
|
||||
import logging
|
||||
from typing import Any, Final, List, cast
|
||||
from typing import Any, List, cast
|
||||
|
||||
import aiotractive
|
||||
|
||||
|
@ -37,10 +37,10 @@ from .const import (
|
|||
TRACKER_POSITION_UPDATED,
|
||||
)
|
||||
|
||||
PLATFORMS: Final = ["binary_sensor", "device_tracker", "sensor", "switch"]
|
||||
PLATFORMS = ["binary_sensor", "device_tracker", "sensor", "switch"]
|
||||
|
||||
|
||||
_LOGGER: Final = logging.getLogger(__name__)
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@dataclass
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
"""Support for Tractive binary sensors."""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Any, Final
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.binary_sensor import (
|
||||
DEVICE_CLASS_BATTERY_CHARGING,
|
||||
|
@ -24,7 +24,7 @@ from .const import (
|
|||
)
|
||||
from .entity import TractiveEntity
|
||||
|
||||
TRACKERS_WITH_BUILTIN_BATTERY: Final = ("TRNJA4", "TRAXL1")
|
||||
TRACKERS_WITH_BUILTIN_BATTERY = ("TRNJA4", "TRAXL1")
|
||||
|
||||
|
||||
class TractiveBinarySensor(TractiveEntity, BinarySensorEntity):
|
||||
|
@ -73,7 +73,7 @@ class TractiveBinarySensor(TractiveEntity, BinarySensorEntity):
|
|||
)
|
||||
|
||||
|
||||
SENSOR_TYPE: Final = BinarySensorEntityDescription(
|
||||
SENSOR_TYPE = BinarySensorEntityDescription(
|
||||
key=ATTR_BATTERY_CHARGING,
|
||||
name="Battery Charging",
|
||||
device_class=DEVICE_CLASS_BATTERY_CHARGING,
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Any, Final
|
||||
from typing import Any
|
||||
|
||||
import aiotractive
|
||||
import voluptuous as vol
|
||||
|
@ -15,9 +15,9 @@ from homeassistant.exceptions import HomeAssistantError
|
|||
|
||||
from .const import DOMAIN
|
||||
|
||||
_LOGGER: Final = logging.getLogger(__name__)
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
USER_DATA_SCHEMA: Final = vol.Schema(
|
||||
USER_DATA_SCHEMA = vol.Schema(
|
||||
{vol.Required(CONF_EMAIL): str, vol.Required(CONF_PASSWORD): str}
|
||||
)
|
||||
|
||||
|
|
|
@ -1,23 +1,22 @@
|
|||
"""Constants for the tractive integration."""
|
||||
|
||||
from datetime import timedelta
|
||||
from typing import Final
|
||||
|
||||
DOMAIN: Final = "tractive"
|
||||
DOMAIN = "tractive"
|
||||
|
||||
RECONNECT_INTERVAL: Final = timedelta(seconds=10)
|
||||
RECONNECT_INTERVAL = timedelta(seconds=10)
|
||||
|
||||
ATTR_DAILY_GOAL: Final = "daily_goal"
|
||||
ATTR_BUZZER: Final = "buzzer"
|
||||
ATTR_LED: Final = "led"
|
||||
ATTR_LIVE_TRACKING: Final = "live_tracking"
|
||||
ATTR_MINUTES_ACTIVE: Final = "minutes_active"
|
||||
ATTR_DAILY_GOAL = "daily_goal"
|
||||
ATTR_BUZZER = "buzzer"
|
||||
ATTR_LED = "led"
|
||||
ATTR_LIVE_TRACKING = "live_tracking"
|
||||
ATTR_MINUTES_ACTIVE = "minutes_active"
|
||||
|
||||
CLIENT: Final = "client"
|
||||
TRACKABLES: Final = "trackables"
|
||||
CLIENT = "client"
|
||||
TRACKABLES = "trackables"
|
||||
|
||||
TRACKER_HARDWARE_STATUS_UPDATED: Final = f"{DOMAIN}_tracker_hardware_status_updated"
|
||||
TRACKER_POSITION_UPDATED: Final = f"{DOMAIN}_tracker_position_updated"
|
||||
TRACKER_ACTIVITY_STATUS_UPDATED: Final = f"{DOMAIN}_tracker_activity_updated"
|
||||
TRACKER_HARDWARE_STATUS_UPDATED = f"{DOMAIN}_tracker_hardware_status_updated"
|
||||
TRACKER_POSITION_UPDATED = f"{DOMAIN}_tracker_position_updated"
|
||||
TRACKER_ACTIVITY_STATUS_UPDATED = f"{DOMAIN}_tracker_activity_updated"
|
||||
|
||||
SERVER_UNAVAILABLE: Final = f"{DOMAIN}_server_unavailable"
|
||||
SERVER_UNAVAILABLE = f"{DOMAIN}_server_unavailable"
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Any, Final
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
|
@ -127,7 +127,7 @@ class TractiveActivitySensor(TractiveSensor):
|
|||
)
|
||||
|
||||
|
||||
SENSOR_TYPES: Final[tuple[TractiveSensorEntityDescription, ...]] = (
|
||||
SENSOR_TYPES: tuple[TractiveSensorEntityDescription, ...] = (
|
||||
TractiveSensorEntityDescription(
|
||||
key=ATTR_BATTERY_LEVEL,
|
||||
name="Battery Level",
|
||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
|
||||
from dataclasses import dataclass
|
||||
import logging
|
||||
from typing import Any, Final, Literal, cast
|
||||
from typing import Any, Literal, cast
|
||||
|
||||
from aiotractive.exceptions import TractiveError
|
||||
|
||||
|
@ -26,7 +26,7 @@ from .const import (
|
|||
)
|
||||
from .entity import TractiveEntity
|
||||
|
||||
_LOGGER: Final = logging.getLogger(__name__)
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -43,7 +43,7 @@ class TractiveSwitchEntityDescription(
|
|||
"""Class describing Tractive switch entities."""
|
||||
|
||||
|
||||
SWITCH_TYPES: Final[tuple[TractiveSwitchEntityDescription, ...]] = (
|
||||
SWITCH_TYPES: tuple[TractiveSwitchEntityDescription, ...] = (
|
||||
TractiveSwitchEntityDescription(
|
||||
key=ATTR_BUZZER,
|
||||
name="Tracker Buzzer",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue