Skip to content

Commit 0552e97

Browse files
committed
Import (Async)Iterator directly
`pydoclint` doesn't resolve basic types, so for the type-checking to be able to match the yield statement we need to use the plain name. More info at: https://jsh9.github.io/pydoclint/notes_for_users.html#2-cases-that-pydoclint-is-not-designed-to-handle Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 21227d6 commit 0552e97

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

tests/conftest.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
# Copyright © 2022 Frequenz Energy-as-a-Service GmbH
33

44
"""Setup for all the tests."""
5-
import collections.abc
65
import contextlib
6+
from collections.abc import Iterator
77
from datetime import timedelta
88

99
import pytest
@@ -16,7 +16,7 @@
1616

1717

1818
@contextlib.contextmanager
19-
def actor_restart_limit(limit: int) -> collections.abc.Iterator[None]:
19+
def actor_restart_limit(limit: int) -> Iterator[None]:
2020
"""Temporarily set the actor restart limit to a given value.
2121
2222
Example:
@@ -41,14 +41,14 @@ def actor_restart_limit(limit: int) -> collections.abc.Iterator[None]:
4141

4242

4343
@pytest.fixture(scope="session", autouse=True)
44-
def disable_actor_auto_restart() -> collections.abc.Iterator[None]:
44+
def disable_actor_auto_restart() -> Iterator[None]:
4545
"""Disable auto-restart of actors while running tests."""
4646
with actor_restart_limit(0):
4747
yield
4848

4949

5050
@pytest.fixture
51-
def actor_auto_restart_once() -> collections.abc.Iterator[None]:
51+
def actor_auto_restart_once() -> Iterator[None]:
5252
"""Make actors restart only once."""
5353
with actor_restart_limit(1):
5454
yield

tests/timeseries/test_periodic_feature_extractor.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33

44
"""Tests for the timeseries averager."""
55

6-
import collections.abc
76
import contextlib
7+
from collections.abc import AsyncIterator
88
from datetime import datetime, timedelta, timezone
99
from typing import List
1010

@@ -28,15 +28,15 @@
2828
@contextlib.asynccontextmanager
2929
async def init_feature_extractor(
3030
data: List[float], period: timedelta
31-
) -> collections.abc.AsyncIterator[PeriodicFeatureExtractor]:
31+
) -> AsyncIterator[PeriodicFeatureExtractor]:
3232
"""
3333
Initialize a PeriodicFeatureExtractor with a `MovingWindow` that contains the data.
3434
3535
Args:
3636
data: The data that is pushed into the moving window.
3737
period: The distance between two successive windows.
3838
39-
Returns:
39+
Yields:
4040
PeriodicFeatureExtractor
4141
"""
4242
window, sender = init_moving_window(timedelta(seconds=len(data)))
@@ -48,14 +48,14 @@ async def init_feature_extractor(
4848
@contextlib.asynccontextmanager
4949
async def init_feature_extractor_no_data(
5050
period: int,
51-
) -> collections.abc.AsyncIterator[PeriodicFeatureExtractor]:
51+
) -> AsyncIterator[PeriodicFeatureExtractor]:
5252
"""
5353
Initialize a PeriodicFeatureExtractor with a `MovingWindow` that contains no data.
5454
5555
Args:
5656
period: The distance between two successive windows.
5757
58-
Returns:
58+
Yields:
5959
PeriodicFeatureExtractor
6060
"""
6161
# We only need the moving window to initialize the PeriodicFeatureExtractor class.

0 commit comments

Comments
 (0)