Skip to content

Commit

Permalink
Merge pull request #2619 from locustio/update-ruff
Browse files Browse the repository at this point in the history
Update ruff to 0.3.0
  • Loading branch information
cyberw committed Mar 1, 2024
2 parents 466d521 + b732877 commit 7f3d735
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 53 deletions.
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ b5324820b299b1fe7da0608f0cc8ec47f58b1e40
60f3bceacc4ab9567433d40ae3ed280750f55ff1
# sort imports using ruff
f99e9df700a8020e4c1967eb42dcb37ddd26e296
# apply ruff 0.3.0
64428a0b4dfc75a00b175b4231db33704d8f5d36
1 change: 1 addition & 0 deletions examples/grpc/hello_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/grpc/hello_pb2_grpc.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
"""Client and server classes corresponding to protobuf-defined services."""

import grpc
import hello_pb2 as hello__pb2

Expand Down
1 change: 1 addition & 0 deletions examples/web_ui_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
For more information, see https://docs.locust.io/en/stable/extending-locust.html#authentication
"""

from locust import HttpUser, events, task

import json
Expand Down
6 changes: 2 additions & 4 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,10 @@ def monitor_cpu_and_memory(self) -> NoReturn:
@abstractmethod
def start(
self, user_count: int, spawn_rate: float, wait: bool = False, user_classes: list[type[User]] | None = None
) -> None:
...
) -> None: ...

@abstractmethod
def send_message(self, msg_type: str, data: Any | None = None, client_id: str | None = None) -> None:
...
def send_message(self, msg_type: str, data: Any | None = None, client_id: str | None = None) -> None: ...

def start_shape(self) -> None:
"""
Expand Down
3 changes: 1 addition & 2 deletions locust/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@

class CSVWriter(Protocol):
@abstractmethod
def writerow(self, columns: Iterable[str | int | float]) -> None:
...
def writerow(self, columns: Iterable[str | int | float]) -> None: ...


class StatsBaseDict(TypedDict):
Expand Down
39 changes: 13 additions & 26 deletions locust/test/test_dispatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3417,14 +3417,11 @@ def case_handler(self, cases: list[RampUpCase], expected: list[dict[str, int]],
self.assertDictEqual(iterations[-1]["1"], expected[case_num], msg=f"Wrong case {case}")

def test_ramp_up_2_weigted_user_with_1_fixed_user(self):
class User1(User):
...
class User1(User): ...

class User2(User):
...
class User2(User): ...

class User3(User):
...
class User3(User): ...

self.case_handler(
cases=[
Expand All @@ -3451,20 +3448,15 @@ class User3(User):
)

def test_ramp_up_various_count_weigted_and_fixed_users(self):
class User1(User):
...
class User1(User): ...

class User2(User):
...
class User2(User): ...

class User3(User):
...
class User3(User): ...

class User4(User):
...
class User4(User): ...

class User5(User):
...
class User5(User): ...

self.case_handler(
cases=[
Expand All @@ -3491,20 +3483,15 @@ class User5(User):
)

def test_ramp_up_only_fixed_users(self):
class User1(User):
...
class User1(User): ...

class User2(User):
...
class User2(User): ...

class User3(User):
...
class User3(User): ...

class User4(User):
...
class User4(User): ...

class User5(User):
...
class User5(User): ...

self.case_handler(
cases=[
Expand Down
6 changes: 2 additions & 4 deletions locust/user/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,11 @@ class TaskHolder(Protocol[TaskT]):


@overload
def task(weight: TaskT) -> TaskT:
...
def task(weight: TaskT) -> TaskT: ...


@overload
def task(weight: int) -> Callable[[TaskT], TaskT]:
...
def task(weight: int) -> Callable[[TaskT], TaskT]: ...


def task(weight: TaskT | int = 1) -> TaskT | Callable[[TaskT], TaskT]:
Expand Down
22 changes: 11 additions & 11 deletions locust/web.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ def _download_csv_response(csv_data: str, filename_prefix: str) -> Response:

response = make_response(csv_data)
response.headers["Content-type"] = "text/csv"
response.headers[
"Content-disposition"
] = f"attachment;filename={_download_csv_suggest_file_name(filename_prefix)}"
response.headers["Content-disposition"] = (
f"attachment;filename={_download_csv_suggest_file_name(filename_prefix)}"
)
return response

@app.route("/stats/requests/csv")
Expand Down Expand Up @@ -425,15 +425,15 @@ def request_stats() -> Response:
for percentile in stats_module.MODERN_UI_PERCENTILES_TO_CHART
}
else:
report[
"current_response_time_percentile_1"
] = environment.runner.stats.total.get_current_response_time_percentile(
stats_module.PERCENTILES_TO_CHART[0]
report["current_response_time_percentile_1"] = (
environment.runner.stats.total.get_current_response_time_percentile(
stats_module.PERCENTILES_TO_CHART[0]
)
)
report[
"current_response_time_percentile_2"
] = environment.runner.stats.total.get_current_response_time_percentile(
stats_module.PERCENTILES_TO_CHART[1]
report["current_response_time_percentile_2"] = (
environment.runner.stats.total.get_current_response_time_percentile(
stats_module.PERCENTILES_TO_CHART[1]
)
)

if isinstance(environment.runner, MasterRunner):
Expand Down
10 changes: 5 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,18 @@ extend-exclude = [
"examples/issue_*.py",
"src/readthedocs-sphinx-search/",
]
ignore = ["E402", "E501", "E713", "E731", "E741", "F401"]
select = ["E", "F", "W", "UP", "FA102", "I001"]
lint.ignore = ["E402", "E501", "E713", "E731", "E741", "F401"]
lint.select = ["E", "F", "W", "UP", "FA102", "I001"]

[tool.ruff.per-file-ignores]
[tool.ruff.lint.per-file-ignores]
"examples/*" = ["F841"]
"locust/test/*" = ["F841"]

[tool.ruff.isort]
[tool.ruff.lint.isort]
section-order = ["future", "locust", "standard-library", "third-party", "first-party", "local-folder"]
# Custom selection-order: to ensure locust is imported as first in lucustfiles (for successful gevent monkey patching)

[tool.ruff.isort.sections]
[tool.ruff.lint.isort.sections]
locust = ["locust"]


Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ commands =
python -m unittest -f locust.test.test_main

[testenv:ruff]
deps = ruff==0.1.13
deps = ruff==0.3.0
commands =
ruff check .
ruff format --check
Expand Down

0 comments on commit 7f3d735

Please sign in to comment.