mirror of https://github.com/locustio/locust.git
Code quality: Fix unused imports and switch on related ruff check
This commit is contained in:
parent
8ceb930253
commit
a8302fc4b5
|
@ -1,6 +1,5 @@
|
||||||
from locust import HttpUser, LoadTestShape, TaskSet, constant, task
|
from locust import HttpUser, LoadTestShape, TaskSet, constant, task
|
||||||
|
|
||||||
import math
|
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
from locust import HttpUser, LoadTestShape, constant, task
|
from locust import HttpUser, LoadTestShape, constant, task
|
||||||
|
|
||||||
import math
|
|
||||||
|
|
||||||
|
|
||||||
class UserA(HttpUser):
|
class UserA(HttpUser):
|
||||||
wait_time = constant(600)
|
wait_time = constant(600)
|
||||||
|
|
|
@ -3,7 +3,7 @@ This is an example of a locustfile that uses Locust's built in event hooks to
|
||||||
track the sum of the content-length header in all successful HTTP responses
|
track the sum of the content-length header in all successful HTTP responses
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from locust import HttpUser, TaskSet, between, events, task, web
|
from locust import HttpUser, TaskSet, between, events, task
|
||||||
|
|
||||||
|
|
||||||
class MyTaskSet(TaskSet):
|
class MyTaskSet(TaskSet):
|
||||||
|
|
|
@ -4,14 +4,14 @@ UI extension hooks to track the sum of the content-length header in all
|
||||||
successful HTTP responses and display them in the web UI.
|
successful HTTP responses and display them in the web UI.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from locust import HttpUser, TaskSet, between, events, task, web
|
from locust import HttpUser, TaskSet, between, events, task
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from html import escape
|
from html import escape
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from flask import Blueprint, jsonify, make_response, render_template, request
|
from flask import Blueprint, make_response, render_template, request
|
||||||
|
|
||||||
|
|
||||||
class MyTaskSet(TaskSet):
|
class MyTaskSet(TaskSet):
|
||||||
|
|
|
@ -20,7 +20,7 @@ Usage as a decorator:
|
||||||
from locust import User, constant, events, task
|
from locust import User, constant, events, task
|
||||||
|
|
||||||
import random
|
import random
|
||||||
from contextlib import ContextDecorator, contextmanager
|
from contextlib import contextmanager
|
||||||
from time import sleep, time
|
from time import sleep, time
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from locust import between, task
|
from locust import task
|
||||||
from locust.contrib.mongodb import MongoDBUser
|
from locust.contrib.mongodb import MongoDBUser
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from locust import TaskSet, between, task
|
from locust import task
|
||||||
from locust.contrib.postgres import PostgresUser
|
from locust.contrib.postgres import PostgresUser
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
from locust import HttpUser, between, task
|
from locust import HttpUser, between, task
|
||||||
|
|
||||||
import time
|
|
||||||
|
|
||||||
|
|
||||||
class Quickstart(HttpUser):
|
class Quickstart(HttpUser):
|
||||||
wait_time = between(1, 5)
|
wait_time = between(1, 5)
|
||||||
|
|
|
@ -4,14 +4,14 @@ UI extension hooks to track the sum of Varnish cache hit/miss headers
|
||||||
and display them in the web UI.
|
and display them in the web UI.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from locust import HttpUser, TaskSet, between, events, task, web
|
from locust import HttpUser, TaskSet, between, events, task
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
from html import escape
|
from html import escape
|
||||||
from time import time
|
from time import time
|
||||||
|
|
||||||
from flask import Blueprint, jsonify, make_response, render_template, request
|
from flask import Blueprint, make_response, render_template, request
|
||||||
|
|
||||||
|
|
||||||
class MyTaskSet(TaskSet):
|
class MyTaskSet(TaskSet):
|
||||||
|
|
|
@ -5,7 +5,7 @@ if os.getenv("LOCUST_PLAYWRIGHT", None):
|
||||||
print("Uninstall trio package and remove the setting.")
|
print("Uninstall trio package and remove the setting.")
|
||||||
try:
|
try:
|
||||||
# preserve backwards compatibility for now
|
# preserve backwards compatibility for now
|
||||||
import trio
|
import trio # noqa: F401
|
||||||
except ModuleNotFoundError:
|
except ModuleNotFoundError:
|
||||||
# dont show a massive callstack if trio is not installed
|
# dont show a massive callstack if trio is not installed
|
||||||
os._exit(1)
|
os._exit(1)
|
||||||
|
@ -50,6 +50,9 @@ __all__ = (
|
||||||
"events",
|
"events",
|
||||||
"LoadTestShape",
|
"LoadTestShape",
|
||||||
"run_single_user",
|
"run_single_user",
|
||||||
|
"HttpLocust",
|
||||||
|
"Locust",
|
||||||
|
"__version__",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Used for raising a DeprecationWarning if old Locust/HttpLocust is used
|
# Used for raising a DeprecationWarning if old Locust/HttpLocust is used
|
||||||
|
|
|
@ -10,7 +10,6 @@ import json
|
||||||
import os
|
import os
|
||||||
import platform
|
import platform
|
||||||
import socket
|
import socket
|
||||||
import ssl
|
|
||||||
import sys
|
import sys
|
||||||
import tempfile
|
import tempfile
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
||||||
from locust.env import Environment
|
from locust.env import Environment
|
||||||
from locust.exception import CatchResponseError, LocustError, ResponseError
|
from locust.exception import CatchResponseError, LocustError, ResponseError
|
||||||
from locust.user import User
|
from locust.user import User
|
||||||
from locust.util.deprecation import DeprecatedFastHttpLocustClass as FastHttpLocust
|
from locust.util.deprecation import DeprecatedFastHttpLocustClass as FastHttpLocust # noqa: F401
|
||||||
|
|
||||||
import json
|
import json
|
||||||
import json as unshadowed_json # some methods take a named parameter called json
|
import json as unshadowed_json # some methods take a named parameter called json
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
import glob
|
|
||||||
import os
|
import os
|
||||||
import pathlib
|
|
||||||
from html import escape
|
from html import escape
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
from json import dumps
|
|
||||||
|
|
||||||
from jinja2 import Environment as JinjaEnvironment
|
from jinja2 import Environment as JinjaEnvironment
|
||||||
from jinja2 import FileSystemLoader
|
from jinja2 import FileSystemLoader
|
||||||
|
|
|
@ -8,7 +8,6 @@ import gc
|
||||||
import importlib.metadata
|
import importlib.metadata
|
||||||
import inspect
|
import inspect
|
||||||
import itertools
|
import itertools
|
||||||
import json
|
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
|
@ -39,12 +38,12 @@ from .util.load_locustfile import load_locustfile
|
||||||
|
|
||||||
# import external plugins if installed to allow for registering custom arguments etc
|
# import external plugins if installed to allow for registering custom arguments etc
|
||||||
try:
|
try:
|
||||||
import locust_plugins # pyright: ignore[reportMissingImports]
|
import locust_plugins # pyright: ignore[reportMissingImports] # noqa: F401
|
||||||
except ModuleNotFoundError as e:
|
except ModuleNotFoundError as e:
|
||||||
if e.msg != "No module named 'locust_plugins'":
|
if e.msg != "No module named 'locust_plugins'":
|
||||||
raise
|
raise
|
||||||
try:
|
try:
|
||||||
import locust_cloud # pyright: ignore[reportMissingImports]
|
import locust_cloud # pyright: ignore[reportMissingImports] # noqa: F401
|
||||||
|
|
||||||
locust_cloud_version = f" (locust-cloud {importlib.metadata.version('locust-cloud')})"
|
locust_cloud_version = f" (locust-cloud {importlib.metadata.version('locust-cloud')})"
|
||||||
except ModuleNotFoundError as e:
|
except ModuleNotFoundError as e:
|
||||||
|
|
|
@ -1,2 +1,7 @@
|
||||||
|
__all__ = (
|
||||||
|
"Message",
|
||||||
|
"rpc",
|
||||||
|
)
|
||||||
|
|
||||||
from . import zmqrpc as rpc
|
from . import zmqrpc as rpc
|
||||||
from .protocol import Message
|
from .protocol import Message
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from locust import FastHttpUser
|
from locust import FastHttpUser
|
||||||
from locust.argument_parser import parse_options
|
|
||||||
from locust.contrib.fasthttp import FastHttpSession
|
from locust.contrib.fasthttp import FastHttpSession
|
||||||
from locust.exception import CatchResponseError, InterruptTaskSet, LocustError, ResponseError
|
from locust.exception import CatchResponseError, InterruptTaskSet, LocustError, ResponseError
|
||||||
from locust.user import TaskSet, task
|
from locust.user import TaskSet, task
|
||||||
|
|
|
@ -6,7 +6,6 @@ from locust.util.load_locustfile import is_user_class
|
||||||
|
|
||||||
import filecmp
|
import filecmp
|
||||||
import os
|
import os
|
||||||
import pathlib
|
|
||||||
import textwrap
|
import textwrap
|
||||||
|
|
||||||
from .mock_locustfile import MOCK_LOCUSTFILE_CONTENT, mock_locustfile
|
from .mock_locustfile import MOCK_LOCUSTFILE_CONTENT, mock_locustfile
|
||||||
|
|
|
@ -9,7 +9,7 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
import unittest
|
import unittest
|
||||||
from subprocess import DEVNULL, PIPE, STDOUT
|
from subprocess import PIPE, STDOUT
|
||||||
from tempfile import TemporaryDirectory
|
from tempfile import TemporaryDirectory
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ from locust.argument_parser import (
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from random import randint
|
|
||||||
from tempfile import NamedTemporaryFile, TemporaryDirectory
|
from tempfile import NamedTemporaryFile, TemporaryDirectory
|
||||||
from unittest import mock
|
from unittest import mock
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from locust import User, constant, task
|
from locust import User, task
|
||||||
from locust.exception import RescheduleTask
|
from locust.exception import RescheduleTask
|
||||||
from locust.user.sequential_taskset import SequentialTaskSet
|
from locust.user.sequential_taskset import SequentialTaskSet
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
from locust import TaskSet, User, between, constant, constant_throughput
|
from locust import TaskSet, User, between, constant, constant_throughput
|
||||||
from locust.exception import MissingWaitTimeError
|
|
||||||
|
|
||||||
import random
|
import random
|
||||||
import time
|
import time
|
||||||
|
|
|
@ -10,24 +10,19 @@ from locust.stats import StatsCSVFileWriter
|
||||||
from locust.user import User, task
|
from locust.user import User, task
|
||||||
from locust.web import WebUI
|
from locust.web import WebUI
|
||||||
|
|
||||||
import copy
|
|
||||||
import csv
|
import csv
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
|
||||||
import textwrap
|
|
||||||
import traceback
|
import traceback
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from tempfile import NamedTemporaryFile, TemporaryDirectory
|
from tempfile import NamedTemporaryFile
|
||||||
|
|
||||||
import gevent
|
import gevent
|
||||||
import requests
|
import requests
|
||||||
from flask_login import UserMixin
|
from flask_login import UserMixin
|
||||||
from pyquery import PyQuery as pq
|
from pyquery import PyQuery as pq
|
||||||
|
|
||||||
from ..util.load_locustfile import load_locustfile
|
|
||||||
from .mock_locustfile import mock_locustfile
|
|
||||||
from .testcases import LocustTestCase
|
from .testcases import LocustTestCase
|
||||||
from .util import create_tls_cert
|
from .util import create_tls_cert
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
from locust.exception import RPCError, RPCReceiveError, RPCSendError
|
from locust.exception import RPCError, RPCSendError
|
||||||
from locust.rpc import Message, zmqrpc
|
from locust.rpc import Message, zmqrpc
|
||||||
from locust.test.testcases import LocustTestCase
|
from locust.test.testcases import LocustTestCase
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,9 @@
|
||||||
|
__all__ = (
|
||||||
|
"HttpUser",
|
||||||
|
"tag",
|
||||||
|
"task",
|
||||||
|
"TaskSet",
|
||||||
|
"User",
|
||||||
|
)
|
||||||
from .task import TaskSet, tag, task
|
from .task import TaskSet, tag, task
|
||||||
from .users import HttpUser, User
|
from .users import HttpUser, User
|
||||||
|
|
|
@ -10,7 +10,6 @@ from html import escape
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
from json import dumps
|
from json import dumps
|
||||||
from time import time
|
|
||||||
from typing import TYPE_CHECKING, Any, TypedDict
|
from typing import TYPE_CHECKING, Any, TypedDict
|
||||||
|
|
||||||
import gevent
|
import gevent
|
||||||
|
|
|
@ -193,7 +193,7 @@ extend-exclude = [
|
||||||
"examples/issue_*.py",
|
"examples/issue_*.py",
|
||||||
"src/readthedocs-sphinx-search/",
|
"src/readthedocs-sphinx-search/",
|
||||||
]
|
]
|
||||||
lint.ignore = ["E402", "E501", "E713", "E731", "E741", "F401"]
|
lint.ignore = ["E402", "E501", "E713", "E731", "E741"]
|
||||||
lint.select = ["E", "F", "W", "UP", "FA102", "I001"]
|
lint.select = ["E", "F", "W", "UP", "FA102", "I001"]
|
||||||
|
|
||||||
[tool.ruff.lint.per-file-ignores]
|
[tool.ruff.lint.per-file-ignores]
|
||||||
|
|
Loading…
Reference in New Issue