|
14 | 14 | from collections.abc import AsyncIterator, Callable, Coroutine, Sequence
|
15 | 15 | from dataclasses import dataclass
|
16 | 16 | from datetime import datetime, timedelta, timezone
|
17 |
| -from typing import cast |
18 | 17 |
|
19 | 18 | from frequenz.channels.timer import Timer, TriggerAllMissed, _to_microseconds
|
20 | 19 | from frequenz.quantities import Quantity
|
@@ -506,19 +505,13 @@ async def resample(self, *, one_shot: bool = False) -> None:
|
506 | 505 | )
|
507 | 506 |
|
508 | 507 | self._window_end += self._config.resampling_period
|
509 |
| - # We need the cast because mypy is not able to infer that this can only |
510 |
| - # contain Exception | CancelledError because of the condition in the list |
511 |
| - # comprehension below. |
512 |
| - exceptions = cast( |
513 |
| - dict[Source, Exception | asyncio.CancelledError], |
514 |
| - { |
515 |
| - source: result |
516 |
| - for source, result in zip(resampler_sources, results) |
517 |
| - # CancelledError inherits from BaseException, but we don't want |
518 |
| - # to catch *all* BaseExceptions here. |
519 |
| - if isinstance(result, (Exception, asyncio.CancelledError)) |
520 |
| - }, |
521 |
| - ) |
| 508 | + exceptions = { |
| 509 | + source: result |
| 510 | + for source, result in zip(resampler_sources, results) |
| 511 | + # CancelledError inherits from BaseException, but we don't want |
| 512 | + # to catch *all* BaseExceptions here. |
| 513 | + if isinstance(result, (Exception, asyncio.CancelledError)) |
| 514 | + } |
522 | 515 | if exceptions:
|
523 | 516 | raise ResamplingError(exceptions)
|
524 | 517 | if one_shot:
|
|
0 commit comments