Update syntax to match what ruff recommends for Python 3.10

This commit is contained in:
Lars Holmberg 2025-04-08 14:16:18 +02:00
parent 0a43546504
commit efc565b02e
8 changed files with 16 additions and 15 deletions

View File

@ -2,7 +2,8 @@ from locust import User
from locust.exception import LocustError from locust.exception import LocustError
import time import time
from typing import Any, Callable from collections.abc import Callable
from typing import Any
import grpc import grpc
import grpc.experimental.gevent as grpc_gevent import grpc.experimental.gevent as grpc_gevent

View File

@ -373,12 +373,10 @@ class ResponseContextManager(LocustResponse):
while ( while (
isinstance( isinstance(
e, e,
( requests.exceptions.ConnectionError
requests.exceptions.ConnectionError, | requests.packages.urllib3.exceptions.ProtocolError
requests.packages.urllib3.exceptions.ProtocolError, | requests.packages.urllib3.exceptions.MaxRetryError
requests.packages.urllib3.exceptions.MaxRetryError, | requests.packages.urllib3.exceptions.NewConnectionError,
requests.packages.urllib3.exceptions.NewConnectionError,
),
) )
and e.__context__ # Not sure if the above exceptions can ever be the lowest level, but it is good to be sure and e.__context__ # Not sure if the above exceptions can ever be the lowest level, but it is good to be sure
): ):

View File

@ -1,7 +1,8 @@
from __future__ import annotations from __future__ import annotations
from collections.abc import Callable
from operator import methodcaller from operator import methodcaller
from typing import Callable, TypeVar from typing import TypeVar
from configargparse import Namespace from configargparse import Namespace

View File

@ -4,7 +4,7 @@ import collections
import logging import logging
import os import os
import sys import sys
from typing import Callable from collections.abc import Callable
import gevent import gevent

View File

@ -14,10 +14,10 @@ import time
import traceback import traceback
from abc import abstractmethod from abc import abstractmethod
from collections import defaultdict from collections import defaultdict
from collections.abc import Iterator, MutableMapping, ValuesView from collections.abc import Callable, Iterator, MutableMapping, ValuesView
from operator import itemgetter, methodcaller from operator import itemgetter, methodcaller
from types import TracebackType from types import TracebackType
from typing import TYPE_CHECKING, Any, Callable, NoReturn, TypedDict, cast from typing import TYPE_CHECKING, Any, NoReturn, TypedDict, cast
from uuid import uuid4 from uuid import uuid4
import gevent import gevent

View File

@ -9,12 +9,12 @@ import signal
import time import time
from abc import abstractmethod from abc import abstractmethod
from collections import OrderedDict, defaultdict, namedtuple from collections import OrderedDict, defaultdict, namedtuple
from collections.abc import Iterable from collections.abc import Callable, Iterable
from copy import copy from copy import copy
from html import escape from html import escape
from itertools import chain from itertools import chain
from types import FrameType from types import FrameType
from typing import TYPE_CHECKING, Any, Callable, NoReturn, Protocol, TypedDict, TypeVar, cast from typing import TYPE_CHECKING, Any, NoReturn, Protocol, TypedDict, TypeVar, cast
import gevent import gevent

View File

@ -6,10 +6,10 @@ import logging
import random import random
import traceback import traceback
from collections import deque from collections import deque
from collections.abc import Callable
from time import time from time import time
from typing import ( from typing import (
TYPE_CHECKING, TYPE_CHECKING,
Callable,
Protocol, Protocol,
TypeVar, TypeVar,
final, final,

View File

@ -16,7 +16,8 @@ from locust.util import deprecation
import logging import logging
import time import time
import traceback import traceback
from typing import Callable, final from collections.abc import Callable
from typing import final
from gevent import GreenletExit, greenlet from gevent import GreenletExit, greenlet
from gevent.pool import Group from gevent.pool import Group