Skip to content

Commit

Permalink
Import from typing instead of typing_extensions, now that we are only…
Browse files Browse the repository at this point in the history
… supporting 3.8+
  • Loading branch information
cyberw committed Oct 12, 2023
1 parent cf43e04 commit 25b7efa
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 28 deletions.
20 changes: 7 additions & 13 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -909,13 +903,13 @@ 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,
)
)
)
or all(
map(
Expand Down
8 changes: 2 additions & 6 deletions locust/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 3 additions & 7 deletions locust/user/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 1 addition & 2 deletions locust/user/users.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 25b7efa

Please sign in to comment.