Skip to content

Commit 78abc63

Browse files
committed
Use properties instead of instance variables in protocol classes
Subtypes just have to emulate this behaviour, so if they have instance variables instead, they will still satisfy the requirements of the protocol. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 251a96c commit 78abc63

File tree

3 files changed

+24
-18
lines changed

3 files changed

+24
-18
lines changed

src/frequenz/sdk/timeseries/battery_pool/_result_types.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,16 @@
1616
class BatteryPoolReport(typing.Protocol):
1717
"""A status report for a battery pool."""
1818

19-
target_power: Power | None
20-
"""The currently set power for the batteries."""
19+
@property
20+
def target_power(self) -> Power | None:
21+
"""The currently set power for the batteries."""
2122

22-
distribution_result: power_distributing.Result | None
23-
"""The result of the last power distribution.
23+
@property
24+
def distribution_result(self) -> power_distributing.Result | None:
25+
"""The result of the last power distribution.
2426
25-
This is `None` if no power distribution has been performed yet.
26-
"""
27+
This is `None` if no power distribution has been performed yet.
28+
"""
2729

2830
@property
2931
def bounds(self) -> Bounds[Power] | None:

src/frequenz/sdk/timeseries/ev_charger_pool/_result_types.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313
class EVChargerPoolReport(typing.Protocol):
1414
"""A status report for an EV chargers pool."""
1515

16-
target_power: Power | None
17-
"""The currently set power for the EV chargers."""
16+
@property
17+
def target_power(self) -> Power | None:
18+
"""The currently set power for the EV chargers."""
1819

19-
distribution_result: power_distributing.Result | None
20-
"""The result of the last power distribution.
20+
@property
21+
def distribution_result(self) -> power_distributing.Result | None:
22+
"""The result of the last power distribution.
2123
22-
This is `None` if no power distribution has been performed yet.
23-
"""
24+
This is `None` if no power distribution has been performed yet.
25+
"""
2426

2527
@property
2628
def bounds(self) -> Bounds[Power] | None:

src/frequenz/sdk/timeseries/pv_pool/_result_types.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@
1313
class PVPoolReport(typing.Protocol):
1414
"""A status report for a PV pool."""
1515

16-
target_power: Power | None
17-
"""The currently set power for the PV inverters."""
16+
@property
17+
def target_power(self) -> Power | None:
18+
"""The currently set power for the PV inverters."""
1819

19-
distribution_result: power_distributing.Result | None
20-
"""The result of the last power distribution.
20+
@property
21+
def distribution_result(self) -> power_distributing.Result | None:
22+
"""The result of the last power distribution.
2123
22-
This is `None` if no power distribution has been performed yet.
23-
"""
24+
This is `None` if no power distribution has been performed yet.
25+
"""
2426

2527
@property
2628
def bounds(self) -> Bounds[Power] | None:

0 commit comments

Comments
 (0)