Use TypedDict to avoir using Any

This commit is contained in:
Edgar P. Burkhart 2024-12-09 16:12:38 +01:00
parent 9a295a7569
commit 483d377b6d
Signed by: edpibu
GPG key ID: 9833D3C5A25BD227
2 changed files with 11 additions and 3 deletions

View file

@ -1,5 +1,5 @@
[logging] [logging]
level = "DEBUG" # level = "DEBUG"
[homeassistant] [homeassistant]
entity = "climate.chaudiere" entity = "climate.chaudiere"

View file

@ -1,7 +1,7 @@
import json import json
import logging import logging
from collections.abc import Callable from collections.abc import Callable
from typing import Any from typing import Any, TypedDict
import paho.mqtt.client as mqtt import paho.mqtt.client as mqtt
from paho.mqtt.enums import CallbackAPIVersion, MQTTErrorCode from paho.mqtt.enums import CallbackAPIVersion, MQTTErrorCode
@ -12,6 +12,14 @@ from .select import Selector
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
class HAOptions(TypedDict):
dev: dict[str, str]
o: dict[str, str]
availability_topic: str
state_topic: str
cmps: dict[str, dict[str, str]]
class HAClient: class HAClient:
def __init__( def __init__(
self, self,
@ -38,7 +46,7 @@ class HAClient:
self.selector = Selector(self.send_data) self.selector = Selector(self.send_data)
@property @property
def ha_options(self) -> dict[str, Any]: def ha_options(self) -> HAOptions:
return { return {
"dev": { "dev": {
"ids": "oin", "ids": "oin",