Skip to content

Commit 0ec6cb8

Browse files
committed
Avoid using deprecated types from typing
Import from `collections.abc` instead, and also use a direct import of `cast` instead of using it from `typing`. Signed-off-by: Leandro Lucarella <[email protected]>
1 parent 17d983a commit 0ec6cb8

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

tests/timeseries/_battery_pool/test_battery_pool_control_methods.py

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

66
import asyncio
77
import dataclasses
8-
import typing
8+
from collections.abc import AsyncIterator, Callable
99
from datetime import datetime, timedelta, timezone
1010
from typing import cast
1111
from unittest.mock import AsyncMock, MagicMock
@@ -55,7 +55,7 @@ class Mocks:
5555

5656

5757
@pytest.fixture
58-
async def mocks(mocker: MockerFixture) -> typing.AsyncIterator[Mocks]:
58+
async def mocks(mocker: MockerFixture) -> AsyncIterator[Mocks]:
5959
"""Fixture for the mocks."""
6060
mockgrid = MockMicrogrid()
6161
mockgrid.add_batteries(4)
@@ -168,7 +168,7 @@ def _assert_report( # pylint: disable=too-many-arguments
168168
upper: float,
169169
dist_result: _power_distributing.Result | None = None,
170170
expected_result_pred: (
171-
typing.Callable[[_power_distributing.Result], bool] | None
171+
Callable[[_power_distributing.Result], bool] | None
172172
) = None,
173173
) -> None:
174174
assert report.target_power == (

tests/timeseries/_ev_charger_pool/test_ev_charger_pool_control_methods.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"""Test the EV charger pool control methods."""
55

66
import asyncio
7-
import typing
7+
from collections.abc import AsyncIterator, Callable
88
from datetime import datetime, timedelta, timezone
99
from typing import cast
1010
from unittest.mock import AsyncMock, MagicMock
@@ -42,7 +42,7 @@ def event_loop_policy() -> async_solipsism.EventLoopPolicy:
4242

4343

4444
@pytest.fixture
45-
async def mocks(mocker: MockerFixture) -> typing.AsyncIterator[_Mocks]:
45+
async def mocks(mocker: MockerFixture) -> AsyncIterator[_Mocks]:
4646
"""Create the mocks."""
4747
mockgrid = MockMicrogrid(grid_meter=True)
4848
mockgrid.add_ev_chargers(4)
@@ -56,7 +56,7 @@ async def mocks(mocker: MockerFixture) -> typing.AsyncIterator[_Mocks]:
5656
)
5757
streamer = MockComponentDataStreamer(mockgrid.mock_client)
5858

59-
dp = typing.cast(_DataPipeline, microgrid._data_pipeline._DATA_PIPELINE)
59+
dp = cast(_DataPipeline, microgrid._data_pipeline._DATA_PIPELINE)
6060

6161
try:
6262
yield _Mocks(
@@ -156,7 +156,7 @@ async def _init_ev_chargers(self, mocks: _Mocks) -> None:
156156
async def _recv_reports_until(
157157
self,
158158
bounds_rx: Receiver[EVChargerPoolReport],
159-
check: typing.Callable[[EVChargerPoolReport], bool],
159+
check: Callable[[EVChargerPoolReport], bool],
160160
) -> EVChargerPoolReport | None:
161161
"""Receive reports until the given condition is met."""
162162
max_reports = 10
@@ -179,7 +179,7 @@ def _assert_report( # pylint: disable=too-many-arguments
179179
upper: float,
180180
dist_result: _power_distributing.Result | None = None,
181181
expected_result_pred: (
182-
typing.Callable[[_power_distributing.Result], bool] | None
182+
Callable[[_power_distributing.Result], bool] | None
183183
) = None,
184184
) -> None:
185185
assert report is not None and report.target_power == (

0 commit comments

Comments
 (0)