diff --git a/locust/runners.py b/locust/runners.py index f6250303de..8327066412 100644 --- a/locust/runners.py +++ b/locust/runners.py @@ -29,15 +29,9 @@ Any, cast, Callable, + TypedDict, ) from uuid import uuid4 - -# @TODO: typing.Protocol is in python >= 3.8 -try: - from typing import Protocol, TypedDict -except ImportError: - from typing_extensions import Protocol, TypedDict # type: ignore - import gevent import greenlet import psutil @@ -836,7 +830,7 @@ def start( logger.info(f"{msg_prefix}: {_format_user_classes_count_for_log(self.reported_user_classes_count)}") - @functools.lru_cache() + @functools.lru_cache def _wait_for_workers_report_after_ramp_up(self) -> float: """ The amount of time to wait after a ramp-up in order for all the workers to report their state @@ -909,13 +903,11 @@ def check_stopped(self) -> None: not self.state == STATE_INIT and not self.state == STATE_STOPPED and ( - ( - self.state == STATE_STOPPING - and all( - map( - lambda x: x.state == STATE_INIT, - self.clients.all, - ) + self.state == STATE_STOPPING + and all( + map( + lambda x: x.state == STATE_INIT, + self.clients.all, ) ) ) diff --git a/locust/stats.py b/locust/stats.py index 0f1bf9abba..4cbfed338c 100644 --- a/locust/stats.py +++ b/locust/stats.py @@ -28,14 +28,10 @@ Callable, TypeVar, cast, + Protocol, + TypedDict, ) -# @TODO: typing.Protocol is in python >= 3.8 -try: - from typing import Protocol, TypedDict -except ImportError: - from typing_extensions import Protocol, TypedDict # type: ignore - from types import FrameType from .exception import CatchResponseError diff --git a/locust/user/task.py b/locust/user/task.py index d9bd895e7e..a09beb7603 100644 --- a/locust/user/task.py +++ b/locust/user/task.py @@ -13,14 +13,10 @@ overload, Dict, Set, + Protocol, + final, + runtime_checkable, ) - -# @TODO: typing.Protocol and typing.final is in python >= 3.8 -try: - from typing import Protocol, final, runtime_checkable -except ImportError: - from typing_extensions import Protocol, final, runtime_checkable # type: ignore - import gevent from gevent import GreenletExit diff --git a/locust/user/users.py b/locust/user/users.py index 3a9e3b1160..bf819c9a7c 100644 --- a/locust/user/users.py +++ b/locust/user/users.py @@ -1,9 +1,8 @@ from __future__ import annotations -from typing import Callable, Dict, List, Optional +from typing import Callable, Dict, List, Optional, final from gevent import GreenletExit, greenlet from gevent.pool import Group -from typing_extensions import final from urllib3 import PoolManager from locust.clients import HttpSession