Skip to content

Commit 02fbd2c

Browse files
committed
Use abc.Set for component_ids in EVChargerPool
`abc.Set` allows us to treat `set`s as read-only, and interchangably with `frozenset`s. Many of the SDK's methods that give out component IDs produce `abc.Set` values, and with this change, such values can directly be used in calls to `ev_charger_pool`. This is also to be consistent with `battery_pool`, which already accepts `abc.Set`. Signed-off-by: Sahas Subramanian <[email protected]>
1 parent b6f4f5f commit 02fbd2c

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

src/frequenz/sdk/microgrid/_data_pipeline.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def producer(self) -> Producer:
154154

155155
def ev_charger_pool(
156156
self,
157-
ev_charger_ids: set[int] | None = None,
157+
ev_charger_ids: abc.Set[int] | None = None,
158158
) -> EVChargerPool:
159159
"""Return the corresponding EVChargerPool instance for the given ids.
160160
@@ -350,7 +350,7 @@ def producer() -> Producer:
350350
return _get().producer()
351351

352352

353-
def ev_charger_pool(ev_charger_ids: set[int] | None = None) -> EVChargerPool:
353+
def ev_charger_pool(ev_charger_ids: abc.Set[int] | None = None) -> EVChargerPool:
354354
"""Return the corresponding EVChargerPool instance for the given ids.
355355
356356
If an EVChargerPool instance for the given ids doesn't exist, a new one is

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def __init__(
7777
self,
7878
channel_registry: ChannelRegistry,
7979
resampler_subscription_sender: Sender[ComponentMetricRequest],
80-
component_ids: set[int] | None = None,
80+
component_ids: abc.Set[int] | None = None,
8181
repeat_interval: timedelta = timedelta(seconds=3.0),
8282
) -> None:
8383
"""Create an `EVChargerPool` instance.
@@ -103,7 +103,7 @@ def __init__(
103103
self._resampler_subscription_sender: Sender[ComponentMetricRequest] = (
104104
resampler_subscription_sender
105105
)
106-
self._component_ids: set[int] = set()
106+
self._component_ids: abc.Set[int] = set()
107107
if component_ids is not None:
108108
self._component_ids = component_ids
109109
else:

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from __future__ import annotations
77

88
import asyncio
9+
from collections import abc
910
from enum import Enum
1011

1112
from frequenz.channels import Merger, Receiver, merge
@@ -78,7 +79,7 @@ def is_ev_connected(self) -> bool:
7879
class StateTracker:
7980
"""A class for keeping track of the states of all EV Chargers in a pool."""
8081

81-
def __init__(self, component_ids: set[int]) -> None:
82+
def __init__(self, component_ids: abc.Set[int]) -> None:
8283
"""Create a `_StateTracker` instance.
8384
8485
Args:

0 commit comments

Comments
 (0)