Skip to content

Commit 6dfde50

Browse files
committed
Make data-class constructors kw-only
For these classes: `ReportRequest`, `Report`, `Proposal`. Also update the uses of these classes that weren't already using kw args. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent 50fc8d3 commit 6dfde50

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/frequenz/sdk/actor/_power_managing/_base_classes.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from .. import power_distributing
2020

2121

22-
@dataclasses.dataclass(frozen=True)
22+
@dataclasses.dataclass(frozen=True, kw_only=True)
2323
class ReportRequest:
2424
"""A request to start a reporting stream."""
2525

@@ -42,7 +42,7 @@ def get_channel_name(self) -> str:
4242
return f"power_manager.report.{self.battery_ids=}.{self.priority=}"
4343

4444

45-
@dataclasses.dataclass(frozen=True)
45+
@dataclasses.dataclass(frozen=True, kw_only=True)
4646
class Report:
4747
"""Current PowerManager report for a set of batteries."""
4848

@@ -73,7 +73,7 @@ class Report:
7373
"""
7474

7575

76-
@dataclasses.dataclass(frozen=True)
76+
@dataclasses.dataclass(frozen=True, kw_only=True)
7777
class Proposal:
7878
"""A proposal for a battery to be charged or discharged."""
7979

src/frequenz/sdk/actor/_power_managing/_matryoshka.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ def get_status(
194194
target_power = self._target_power.get(battery_ids)
195195
if system_bounds.inclusion_bounds is None:
196196
return Report(
197-
target_power, None, system_bounds.exclusion_bounds, distribution_result
197+
target_power=target_power,
198+
inclusion_bounds=None,
199+
exclusion_bounds=system_bounds.exclusion_bounds,
200+
distribution_result=distribution_result,
198201
)
199202

200203
lower_bound = system_bounds.inclusion_bounds.lower
@@ -216,7 +219,7 @@ def get_status(
216219
else:
217220
break
218221
return Report(
219-
target_power,
222+
target_power=target_power,
220223
inclusion_bounds=timeseries.Bounds[Power](
221224
lower=lower_bound, upper=upper_bound
222225
),

0 commit comments

Comments
 (0)