Skip to content

Commit 2ebed70

Browse files
committed
WIP part 3: Fix some mypy issues
Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 39dd0ec commit 2ebed70

File tree

3 files changed

+19
-11
lines changed

3 files changed

+19
-11
lines changed

src/frequenz/sdk/microgrid/_data_pipeline.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def __init__(
8888
"""
8989
from ..actor import ChannelRegistry
9090

91-
self._resampler_config: ResamplerConfig = resampler_config
91+
self._resampler_config: ResamplingActorConfig = resampler_config
9292

9393
self._channel_registry: ChannelRegistry = ChannelRegistry(
9494
name="Data Pipeline Registry"

src/frequenz/sdk/timeseries/_resampling.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from collections.abc import AsyncIterator, Callable, Coroutine, Sequence
1515
from dataclasses import dataclass
1616
from datetime import datetime, timedelta, timezone
17-
from typing import Generic
17+
from typing import Generic, cast
1818

1919
from frequenz.channels.util import Timer
2020
from frequenz.channels.util._timer import _to_microseconds
@@ -73,7 +73,12 @@
7373

7474

7575
ResamplingFunction = Callable[
76-
[Sequence[Sample[SupportsFloatT]], "ResamplerConfig", "SourceProperties"], float
76+
[
77+
Sequence[Sample[SupportsFloatT]],
78+
"ResamplerConfig[SupportsFloatT]",
79+
"SourceProperties",
80+
],
81+
float,
7782
]
7883
"""Resampling function type.
7984
@@ -505,13 +510,16 @@ async def resample(self, *, one_shot: bool = False) -> None:
505510
)
506511

507512
self._window_end += self._config.resampling_period
508-
exceptions = {
509-
source: results[i]
510-
for i, source in enumerate(self._resamplers)
511-
# CancelledError inherits from BaseException, but we don't want
512-
# to catch *all* BaseExceptions here.
513-
if isinstance(results[i], (Exception, asyncio.CancelledError))
514-
}
513+
exceptions = cast(
514+
dict[Source[SupportsFloatT], Exception | asyncio.CancelledError],
515+
{
516+
source: results[i]
517+
for i, source in enumerate(self._resamplers)
518+
# CancelledError inherits from BaseException, but we don't want
519+
# to catch *all* BaseExceptions here.
520+
if isinstance(results[i], (Exception, asyncio.CancelledError))
521+
},
522+
)
515523
if exceptions:
516524
raise ResamplingError(exceptions)
517525
if one_shot:

src/frequenz/sdk/timeseries/_voltage_streamer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ async def _send_request(self) -> None:
172172
msg = Sample3Phase(
173173
phases[0].timestamp,
174174
*map(
175-
lambda p: Voltage.from_volts(p.value.base_value)
175+
lambda p: Voltage.from_volts(float(p.value))
176176
if p.value
177177
else None,
178178
phases,

0 commit comments

Comments
 (0)