Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make dataclasses frozen #482

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from .modbus_sensor import ModbusSensorDescription


@dataclass(kw_only=True)
@dataclass(kw_only=True, frozen=True)
class ModbusBatterySensorDescription(ModbusSensorDescription):
"""Description for ModbusBatterySensor"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
_LOGGER = logging.getLogger(__name__)


@dataclass(kw_only=True)
@dataclass(kw_only=True, frozen=True)
class ModbusBinarySensorDescription(BinarySensorEntityDescription, EntityFactory):
"""Description for ModbusBinarySensor"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
# mypy: disable-error-code="call-arg"


@dataclass
@dataclass(frozen=True)
class ModbusChargePeriodAddressConfig:
"""Defines the set of registers which are used to define a charge period"""

Expand All @@ -31,7 +31,7 @@ class ModbusChargePeriodAddressConfig:
enable_charge_from_grid_address: int


@dataclass
@dataclass(frozen=True)
class ModbusChargePeriodInfo:
addresses: ModbusChargePeriodAddressConfig
period_start_entity_id: str
Expand Down Expand Up @@ -89,7 +89,7 @@ def get_enable_charge_from_grid_address(self) -> InverterModelSpec:
return ModbusAddressSpecBase(self.models, addresses)


@dataclass
@dataclass(frozen=True)
class ModbusChargePeriodFactory:
"""
Factory which creates various things required to define and specify a charge period
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _is_force_charge_enabled(
return start_or_end_1 > 0 or start_or_end_2 > 0


@dataclass(kw_only=True)
@dataclass(kw_only=True, frozen=True)
class ModbusChargePeriodStartEndSensorDescription(SensorEntityDescription, EntityFactory):
"""Entity description for ModbusChargePeriodStartEndSensor"""

Expand Down Expand Up @@ -179,7 +179,7 @@ def addresses(self) -> list[int]:
return [self._address, self._other_address]


@dataclass(kw_only=True)
@dataclass(kw_only=True, frozen=True)
class ModbusEnableForceChargeSensorDescription(BinarySensorEntityDescription, EntityFactory):
"""Entity description for ModbusEnableForceChargeSensor"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
assert any(fault for fault_list in _FAULTS for fault in fault_list if fault == assert_mask)


@dataclass(kw_only=True)
@dataclass(kw_only=True, frozen=True)
class ModbusFaultSensorDescription(SensorEntityDescription, EntityFactory):
"""Description for ModbusFaultSensor"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
]


@dataclass(kw_only=True)
@dataclass(kw_only=True, frozen=True)
class ModbusInverterStateSensorDescription(SensorEntityDescription, EntityFactory):
"""Description for ModbusInverterStateSensor"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
_LOGGER = logging.getLogger(__name__)


@dataclass(kw_only=True)
@dataclass(kw_only=True, frozen=True)
class ModbusLambdaSensorDescription(SensorEntityDescription, EntityFactory):
"""Entity description for ModbusLambdaSensors"""

Expand Down
2 changes: 1 addition & 1 deletion custom_components/foxess_modbus/entities/modbus_number.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
_LOGGER: logging.Logger = logging.getLogger(__package__)


@dataclass(kw_only=True)
@dataclass(kw_only=True, frozen=True)
class ModbusNumberDescription(NumberEntityDescription, EntityFactory):
"""Custom number entity description"""

Expand Down
2 changes: 1 addition & 1 deletion custom_components/foxess_modbus/entities/modbus_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
_LOGGER = logging.getLogger(__name__)


@dataclass(kw_only=True)
@dataclass(kw_only=True, frozen=True)
class ModbusSensorDescription(SensorEntityDescription, EntityFactory):
"""Custom sensor description"""

Expand Down
Loading