From 1e56fa388170fbf9b5a855eb06959c7ceafbf48d Mon Sep 17 00:00:00 2001 From: maslyankov Date: Fri, 3 Jan 2025 13:10:56 +0200 Subject: [PATCH] Refactor RWSensor class: Update min and max attributes to use Sensor[Any] for improved type handling and cast dependencies in the dependencies method to ensure correct type resolution. --- src/sunsynk/rwsensors.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/sunsynk/rwsensors.py b/src/sunsynk/rwsensors.py index 505a88cd..7d06cda4 100644 --- a/src/sunsynk/rwsensors.py +++ b/src/sunsynk/rwsensors.py @@ -4,7 +4,7 @@ import logging import re -from typing import Callable, Generator +from typing import Any, Callable, Generator, cast import attrs from mqtt_entity.utils import BOOL_OFF, BOOL_ON @@ -20,8 +20,8 @@ class RWSensor(Sensor[SensorType]): """Read & write sensor.""" - min: SensorType | NumType = 0 - max: SensorType | NumType = 0xFFFF + min: Sensor[Any] | NumType = 0 + max: Sensor[Any] | NumType = 0xFFFF def reg(self, *regs: int, msg: str = "") -> RegType: """Check the registers are within the bitmask.""" @@ -57,9 +57,9 @@ def dependencies(self) -> list[SensorType]: """Dependencies.""" deps: list[SensorType] = [] if isinstance(self.min, Sensor): - deps.append(self.min) + deps.append(cast(SensorType, self.min)) if isinstance(self.max, Sensor): - deps.append(self.max) + deps.append(cast(SensorType, self.max)) return deps