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
|
||||
|
||||
import math
|
||||
import random
|
||||
import time
|
||||
from collections import namedtuple
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
from locust import HttpUser, LoadTestShape, constant, task
|
||||
|
||||
import math
|
||||
|
||||
|
||||
class UserA(HttpUser):
|
||||
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
|
||||
"""
|
||||
|
||||
from locust import HttpUser, TaskSet, between, events, task, web
|
||||
from locust import HttpUser, TaskSet, between, events, task
|
||||
|
||||
|
||||
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.
|
||||
"""
|
||||
|
||||
from locust import HttpUser, TaskSet, between, events, task, web
|
||||
from locust import HttpUser, TaskSet, between, events, task
|
||||
|
||||
import json
|
||||
import os
|
||||
from html import escape
|
||||
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):
|
||||
|
|
|
@ -20,7 +20,7 @@ Usage as a decorator:
|
|||
from locust import User, constant, events, task
|
||||
|
||||
import random
|
||||
from contextlib import ContextDecorator, contextmanager
|
||||
from contextlib import contextmanager
|
||||
from time import sleep, time
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from locust import between, task
|
||||
from locust import task
|
||||
from locust.contrib.mongodb import MongoDBUser
|
||||
|
||||
import os
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from locust import TaskSet, between, task
|
||||
from locust import task
|
||||
from locust.contrib.postgres import PostgresUser
|
||||
|
||||
import os
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
from locust import HttpUser, between, task
|
||||
|
||||
import time
|
||||
|
||||
|
||||
class Quickstart(HttpUser):
|
||||
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.
|
||||
"""
|
||||
|
||||
from locust import HttpUser, TaskSet, between, events, task, web
|
||||
from locust import HttpUser, TaskSet, between, events, task
|
||||
|
||||
import json
|
||||
import os
|
||||
from html import escape
|
||||
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):
|
||||
|
|
|
@ -5,7 +5,7 @@ if os.getenv("LOCUST_PLAYWRIGHT", None):
|
|||
print("Uninstall trio package and remove the setting.")
|
||||
try:
|
||||
# preserve backwards compatibility for now
|
||||
import trio
|
||||
import trio # noqa: F401
|
||||
except ModuleNotFoundError:
|
||||
# dont show a massive callstack if trio is not installed
|
||||
os._exit(1)
|
||||
|
@ -50,6 +50,9 @@ __all__ = (
|
|||
"events",
|
||||
"LoadTestShape",
|
||||
"run_single_user",
|
||||
"HttpLocust",
|
||||
"Locust",
|
||||
"__version__",
|
||||
)
|
||||
|
||||
# Used for raising a DeprecationWarning if old Locust/HttpLocust is used
|
||||
|
|
|
@ -10,7 +10,6 @@ import json
|
|||
import os
|
||||
import platform
|
||||
import socket
|
||||
import ssl
|
||||
import sys
|
||||
import tempfile
|
||||
import textwrap
|
||||
|
|
|
@ -3,7 +3,7 @@ from __future__ import annotations
|
|||
from locust.env import Environment
|
||||
from locust.exception import CatchResponseError, LocustError, ResponseError
|
||||
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 as unshadowed_json # some methods take a named parameter called json
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
import glob
|
||||
import os
|
||||
import pathlib
|
||||
from html import escape
|
||||
from itertools import chain
|
||||
from json import dumps
|
||||
|
||||
from jinja2 import Environment as JinjaEnvironment
|
||||
from jinja2 import FileSystemLoader
|
||||
|
|
|
@ -8,7 +8,6 @@ import gc
|
|||
import importlib.metadata
|
||||
import inspect
|
||||
import itertools
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
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
|
||||
try:
|
||||
import locust_plugins # pyright: ignore[reportMissingImports]
|
||||
import locust_plugins # pyright: ignore[reportMissingImports] # noqa: F401
|
||||
except ModuleNotFoundError as e:
|
||||
if e.msg != "No module named 'locust_plugins'":
|
||||
raise
|
||||
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')})"
|
||||
except ModuleNotFoundError as e:
|
||||
|
|
|
@ -1,2 +1,7 @@
|
|||
__all__ = (
|
||||
"Message",
|
||||
"rpc",
|
||||
)
|
||||
|
||||
from . import zmqrpc as rpc
|
||||
from .protocol import Message
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from locust import FastHttpUser
|
||||
from locust.argument_parser import parse_options
|
||||
from locust.contrib.fasthttp import FastHttpSession
|
||||
from locust.exception import CatchResponseError, InterruptTaskSet, LocustError, ResponseError
|
||||
from locust.user import TaskSet, task
|
||||
|
|
|
@ -6,7 +6,6 @@ from locust.util.load_locustfile import is_user_class
|
|||
|
||||
import filecmp
|
||||
import os
|
||||
import pathlib
|
||||
import textwrap
|
||||
|
||||
from .mock_locustfile import MOCK_LOCUSTFILE_CONTENT, mock_locustfile
|
||||
|
|
|
@ -9,7 +9,7 @@ import subprocess
|
|||
import sys
|
||||
import textwrap
|
||||
import unittest
|
||||
from subprocess import DEVNULL, PIPE, STDOUT
|
||||
from subprocess import PIPE, STDOUT
|
||||
from tempfile import TemporaryDirectory
|
||||
from unittest import TestCase
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@ from locust.argument_parser import (
|
|||
import os
|
||||
import unittest
|
||||
from io import StringIO
|
||||
from random import randint
|
||||
from tempfile import NamedTemporaryFile, TemporaryDirectory
|
||||
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.user.sequential_taskset import SequentialTaskSet
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from locust import TaskSet, User, between, constant, constant_throughput
|
||||
from locust.exception import MissingWaitTimeError
|
||||
|
||||
import random
|
||||
import time
|
||||
|
|
|
@ -10,24 +10,19 @@ from locust.stats import StatsCSVFileWriter
|
|||
from locust.user import User, task
|
||||
from locust.web import WebUI
|
||||
|
||||
import copy
|
||||
import csv
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import textwrap
|
||||
import traceback
|
||||
from io import StringIO
|
||||
from tempfile import NamedTemporaryFile, TemporaryDirectory
|
||||
from tempfile import NamedTemporaryFile
|
||||
|
||||
import gevent
|
||||
import requests
|
||||
from flask_login import UserMixin
|
||||
from pyquery import PyQuery as pq
|
||||
|
||||
from ..util.load_locustfile import load_locustfile
|
||||
from .mock_locustfile import mock_locustfile
|
||||
from .testcases import LocustTestCase
|
||||
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.test.testcases import LocustTestCase
|
||||
|
||||
|
|
|
@ -1,2 +1,9 @@
|
|||
__all__ = (
|
||||
"HttpUser",
|
||||
"tag",
|
||||
"task",
|
||||
"TaskSet",
|
||||
"User",
|
||||
)
|
||||
from .task import TaskSet, tag, task
|
||||
from .users import HttpUser, User
|
||||
|
|
|
@ -10,7 +10,6 @@ from html import escape
|
|||
from io import StringIO
|
||||
from itertools import chain
|
||||
from json import dumps
|
||||
from time import time
|
||||
from typing import TYPE_CHECKING, Any, TypedDict
|
||||
|
||||
import gevent
|
||||
|
|
|
@ -193,7 +193,7 @@ extend-exclude = [
|
|||
"examples/issue_*.py",
|
||||
"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"]
|
||||
|
||||
[tool.ruff.lint.per-file-ignores]
|
||||
|
|
Loading…
Reference in New Issue