Skip to content

Commit

Permalink
Made Sensor class generic with SensorType, Made RWSensor extend the g…
Browse files Browse the repository at this point in the history
…eneric Sensor class. This should resolve the type checking errors while maintaining the existing functionality.
  • Loading branch information
maslyankov committed Jan 3, 2025
1 parent c9c136b commit 346b59a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/sunsynk/rwsensors.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


@attrs.define(slots=True, eq=False)
class RWSensor(Sensor):
class RWSensor(Sensor[SensorType]):
"""Read & write sensor."""

min: SensorType | NumType = 0
Expand Down
6 changes: 3 additions & 3 deletions src/sunsynk/sensors.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Sensor classes represent modbus registers for an inverter."""

from __future__ import annotations
from typing import TypeVar
from typing import TypeVar, Generic

import logging

Expand All @@ -19,11 +19,11 @@

_LOGGER = logging.getLogger(__name__)

SensorType = TypeVar("SensorType", bound="Sensor")
SensorType = TypeVar('SensorType', bound='Sensor')


@attrs.define(slots=True, eq=False)
class Sensor:
class Sensor(Generic[SensorType]):
"""Sunsynk sensor."""

# pylint: disable=too-many-instance-attributes
Expand Down

0 comments on commit 346b59a

Please sign in to comment.