Skip to content

Commit a10062b

Browse files
committed
Don't use generics unnecessarily
Now that we have all actors inheriting from a (public) Actor class there is no need to use generics to specify the type of the actor in the _ActorInfo class. This also fixes a pylint error because the generic type doesn't have the member functions we are calling (like `start()` and `stop()`). Signed-off-by: Leandro Lucarella <[email protected]>
1 parent a51e816 commit a10062b

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

src/frequenz/sdk/microgrid/_data_pipeline.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
from frequenz.channels import Broadcast, Sender
1919

20+
from ..actor._actor import Actor
2021
from ..microgrid.component import Component
2122
from ..timeseries._grid_frequency import GridFrequency
2223
from . import connection_manager
@@ -29,12 +30,7 @@
2930
#
3031
# pylint: disable=import-outside-toplevel
3132
if typing.TYPE_CHECKING:
32-
from ..actor import (
33-
ComponentMetricRequest,
34-
ComponentMetricsResamplingActor,
35-
DataSourcingActor,
36-
ResamplerConfig,
37-
)
33+
from ..actor import ComponentMetricRequest, ResamplerConfig
3834
from ..actor.power_distributing import ( # noqa: F401 (imports used by string type hints)
3935
BatteryStatus,
4036
PowerDistributingActor,
@@ -52,15 +48,12 @@
5248
requests and will be able to keep up with higher request rates in larger installations.
5349
"""
5450

55-
_T = typing.TypeVar("_T")
56-
"""Type variable for generic actor types."""
57-
5851

5952
@dataclass
60-
class _ActorInfo(typing.Generic[_T]):
53+
class _ActorInfo:
6154
"""Holds instances of core data pipeline actors and their request channels."""
6255

63-
actor: _T
56+
actor: Actor
6457
"""The actor instance."""
6558

6659
channel: Broadcast[ComponentMetricRequest]
@@ -90,10 +83,8 @@ def __init__(
9083

9184
self._channel_registry = ChannelRegistry(name="Data Pipeline Registry")
9285

93-
self._data_sourcing_actor: _ActorInfo[DataSourcingActor] | None = None
94-
self._resampling_actor: _ActorInfo[
95-
ComponentMetricsResamplingActor
96-
] | None = None
86+
self._data_sourcing_actor: _ActorInfo | None = None
87+
self._resampling_actor: _ActorInfo | None = None
9788

9889
self._battery_status_channel = Broadcast["BatteryStatus"](
9990
"battery-status", resend_latest=True

0 commit comments

Comments
 (0)