From 0b384646509c60669e85f84ee617d2b509a8a9ce Mon Sep 17 00:00:00 2001 From: Lars Holmberg Date: Thu, 12 Oct 2023 12:37:59 +0200 Subject: [PATCH 1/4] Stop supporting Python 3.7 --- .github/workflows/tests.yml | 1 - locust/main.py | 3 --- pyproject.toml | 3 +-- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2f0c80ae17..4ab801cda1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -25,7 +25,6 @@ jobs: - { name: "3.10", python: "3.10", os: ubuntu-latest, tox: py310 } - { name: "3.9", python: "3.9", os: ubuntu-latest, tox: py39 } - { name: "3.8", python: "3.8", os: ubuntu-latest, tox: py38 } - - { name: "3.7", python: "3.7", os: ubuntu-latest, tox: py37 } steps: - uses: actions/checkout@v3 diff --git a/locust/main.py b/locust/main.py index 1542afa97b..006ed58af4 100644 --- a/locust/main.py +++ b/locust/main.py @@ -210,9 +210,6 @@ def is_valid_percentile(parameter): See https://github.com/locustio/locust/wiki/Installation#increasing-maximum-number-of-open-files-limit for more info.""" ) - if sys.version_info <= (3, 8): - logger.info("Python 3.7 support is deprecated and will be removed soon") - # create locust Environment locustfile_path = None if not locustfile else os.path.basename(locustfile) diff --git a/pyproject.toml b/pyproject.toml index 8cd1f729ba..c7fd616aad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ name = "locust" license = { text = "MIT"} description = "Developer friendly load testing framework" dynamic = ["version"] -requires-python = ">=3.7" +requires-python = ">=3.8" dependencies = [ "gevent >=20.12.1", "flask >=2.0.0", @@ -31,7 +31,6 @@ classifiers = [ "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", - "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", From 85a2c23b08ce899d5eee798973aa4f9848193600 Mon Sep 17 00:00:00 2001 From: Lars Holmberg Date: Thu, 12 Oct 2023 12:40:24 +0200 Subject: [PATCH 2/4] Remove dependency on typing-extensions, it was only needed for Python 3.7 --- pyproject.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index c7fd616aad..6427931ce3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,6 @@ dependencies = [ "Flask-BasicAuth >=0.2.0", "Flask-Cors >=3.0.10", "roundrobin >=0.0.2", - "typing-extensions >=3.7.4.3", # This provides support for @final, @runtime_checkable, Protocol and TypedDict, and can probably be removed once we drop 3.7 support "pywin32;platform_system=='Windows'", ] classifiers = [ From e03666c361c19756ed6df2a55d08ed9b12e6fc92 Mon Sep 17 00:00:00 2001 From: Lars Holmberg Date: Fri, 13 Oct 2023 12:11:06 +0200 Subject: [PATCH 3/4] Skip flaky test on Python 3.8. --- locust/test/test_main.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/locust/test/test_main.py b/locust/test/test_main.py index 0102a4456a..7bbd5777bd 100644 --- a/locust/test/test_main.py +++ b/locust/test/test_main.py @@ -2,7 +2,9 @@ import json import os +import sys import platform +import unittest import pty import signal @@ -11,7 +13,6 @@ from tempfile import TemporaryDirectory from unittest import TestCase from subprocess import PIPE, STDOUT, DEVNULL - import gevent import requests @@ -435,6 +436,7 @@ def my_task(self): self.assertIn("Shutting down (exit code 0)", stderr) self.assertEqual(0, proc.returncode) + @unittest.skipIf(sys.version_info < (3, 9), reason="dies in 3.8 on GH and I cant be bothered to investigate it") def test_default_headless_spawn_options_with_shape(self): content = MOCK_LOCUSTFILE_CONTENT + textwrap.dedent( """ From 933d8ed643068473a88687c5c9bb74e5e6e59c27 Mon Sep 17 00:00:00 2001 From: Lars Holmberg Date: Fri, 13 Oct 2023 12:11:39 +0200 Subject: [PATCH 4/4] Import from typing instead of typing_extensions, now that we are only supporting 3.8+ --- locust/runners.py | 22 +++++++--------------- locust/stats.py | 8 ++------ locust/user/task.py | 10 +++------- locust/user/users.py | 3 +-- 4 files changed, 13 insertions(+), 30 deletions(-) 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