diff --git a/src/_ert/forward_model_runner/client.py b/src/_ert/forward_model_runner/client.py index 3bd75980006..cc81a441e5d 100644 --- a/src/_ert/forward_model_runner/client.py +++ b/src/_ert/forward_model_runner/client.py @@ -3,11 +3,10 @@ import asyncio import logging import uuid -from typing import Any, AnyStr, Self +from typing import Any, Self import zmq import zmq.asyncio -from typing_extensions import Self from _ert.async_utils import new_event_loop @@ -25,7 +24,7 @@ class ClientConnectionClosedOK(Exception): class Client: DEFAULT_MAX_RETRIES = 5 DEFAULT_ACK_TIMEOUT = 5 - _receiver_task: Optional[asyncio.Task[None]] + _receiver_task: asyncio.Task[None] | None def __enter__(self) -> Self: self.loop.run_until_complete(self.__aenter__()) @@ -103,7 +102,7 @@ async def connect(self) -> None: self.term() raise - def send(self, message: str, retries: Optional[int] = None) -> None: + def send(self, message: str, retries: int | None = None) -> None: self.loop.run_until_complete(self._send(message, retries)) async def process_message(self, msg: str) -> None: @@ -137,7 +136,7 @@ async def _send(self, message: str, retries: int | None = None) -> None: self._ack_event.wait(), timeout=self._ack_timeout ) return - except asyncio.TimeoutError: + except TimeoutError: logger.warning( f"{self.dealer_id} failed to get acknowledgment on the {message}. Resending." ) diff --git a/src/ert/ensemble_evaluator/_ensemble.py b/src/ert/ensemble_evaluator/_ensemble.py index 619b19537c8..10087770623 100644 --- a/src/ert/ensemble_evaluator/_ensemble.py +++ b/src/ert/ensemble_evaluator/_ensemble.py @@ -6,7 +6,7 @@ from collections.abc import Awaitable, Callable, Sequence from dataclasses import dataclass from functools import partialmethod -from typing import Any, Awaitable, Callable, Protocol, Sequence +from typing import Any, Protocol from _ert.events import ( Event, diff --git a/src/ert/ensemble_evaluator/config.py b/src/ert/ensemble_evaluator/config.py index 0fc59dcfb47..1d7a2c2f4f0 100644 --- a/src/ert/ensemble_evaluator/config.py +++ b/src/ert/ensemble_evaluator/config.py @@ -5,7 +5,7 @@ import uuid import warnings from base64 import b64encode -from datetime import datetime, timedelta +from datetime import UTC, datetime, timedelta import zmq from cryptography import x509 diff --git a/src/ert/ensemble_evaluator/evaluator.py b/src/ert/ensemble_evaluator/evaluator.py index 5807e9e039f..3b1696bc753 100644 --- a/src/ert/ensemble_evaluator/evaluator.py +++ b/src/ert/ensemble_evaluator/evaluator.py @@ -55,7 +55,7 @@ def __init__(self, ensemble: Ensemble, config: EvaluatorServerConfig): self._events_to_send: asyncio.Queue[Event] = asyncio.Queue() self._manifest_queue: asyncio.Queue[Any] = asyncio.Queue() - self._ee_tasks: List[asyncio.Task[None]] = [] + self._ee_tasks: list[asyncio.Task[None]] = [] self._server_done: asyncio.Event = asyncio.Event() # batching section @@ -292,7 +292,7 @@ async def _server(self) -> None: await self._server_done.wait() try: await asyncio.wait_for(self._dispatchers_empty.wait(), timeout=5) - except asyncio.TimeoutError: + except TimeoutError: logger.warning( "Not all dispatchers were disconnected when closing zmq server!" ) @@ -304,7 +304,7 @@ async def _server(self) -> None: await self._events_to_send.join() try: await asyncio.wait_for(self._clients_empty.wait(), timeout=5) - except asyncio.TimeoutError: + except TimeoutError: logger.warning( "Not all clients were disconnected when closing zmq server!" ) diff --git a/src/ert/ensemble_evaluator/monitor.py b/src/ert/ensemble_evaluator/monitor.py index 52bd7197bbf..90e8fc274d8 100644 --- a/src/ert/ensemble_evaluator/monitor.py +++ b/src/ert/ensemble_evaluator/monitor.py @@ -30,7 +30,7 @@ class EventSentinel: class Monitor(Client): _sentinel: Final = EventSentinel() - def __init__(self, ee_con_info: "EvaluatorConnectionInfo") -> None: + def __init__(self, ee_con_info: EvaluatorConnectionInfo) -> None: self._id = str(uuid.uuid1()).split("-", maxsplit=1)[0] self._event_queue: asyncio.Queue[Event | EventSentinel] = asyncio.Queue() self._receiver_timeout: float = 60.0 diff --git a/tests/ert/conftest.py b/tests/ert/conftest.py index 131e32c2925..e74a875e132 100644 --- a/tests/ert/conftest.py +++ b/tests/ert/conftest.py @@ -210,16 +210,16 @@ def copy_heat_equation(copy_case): pytest.param(0, marks=pytest.mark.xdist_group(name="snake_oil_case_storage")) ], ) -def fixture_copy_snake_oil_case_storage(_shared_snake_oil_case, tmp_path, monkeypatch): +def fixture_copy_snake_oil_case_storage(shared_snake_oil_case, tmp_path, monkeypatch): monkeypatch.chdir(tmp_path) - shutil.copytree(_shared_snake_oil_case, "test_data") + shutil.copytree(shared_snake_oil_case, "test_data") monkeypatch.chdir("test_data") @pytest.fixture -def copy_heat_equation_storage(_shared_heat_equation, tmp_path, monkeypatch): +def copy_heat_equation_storage(shared_heat_equation, tmp_path, monkeypatch): monkeypatch.chdir(tmp_path) - shutil.copytree(_shared_heat_equation, "heat_equation") + shutil.copytree(shared_heat_equation, "heat_equation") monkeypatch.chdir("heat_equation") diff --git a/tests/ert/ui_tests/gui/conftest.py b/tests/ert/ui_tests/gui/conftest.py index 6590180b9d5..c9cb07e37c9 100644 --- a/tests/ert/ui_tests/gui/conftest.py +++ b/tests/ert/ui_tests/gui/conftest.py @@ -183,9 +183,9 @@ def _evaluate(coeffs, x): @pytest.fixture -def esmda_has_run(_esmda_run, tmp_path, monkeypatch): +def esmda_has_run(esmda_run, tmp_path, monkeypatch): monkeypatch.chdir(tmp_path) - shutil.copytree(_esmda_run, tmp_path, dirs_exist_ok=True) + shutil.copytree(esmda_run, tmp_path, dirs_exist_ok=True) with ( _open_main_window(tmp_path / "poly.ert") as ( gui,