Skip to content

Update ruff to 0.10.0 #3079

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ b5324820b299b1fe7da0608f0cc8ec47f58b1e40
f99e9df700a8020e4c1967eb42dcb37ddd26e296
# apply ruff 0.3.0
64428a0b4dfc75a00b175b4231db33704d8f5d36
# apply ruff 0.10.0
92268e16d5666d429ccea1742ecb90475f284c89
496c5bd40347b97f917ccacfaf57ceed8f6690b5
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.7.3 # Pin the same version in the pyproject.toml file
rev: v0.10.0 # Pin the same version in the pyproject.toml file
hooks:
# Run the linter.
- id: ruff
Expand Down
2 changes: 1 addition & 1 deletion examples/extend_web_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def content_length_csv():

if stats:
for url, inner_stats in stats.items():
rows.append(f"\"{url}\",{inner_stats['content-length']:.2f}")
rows.append(f'"{url}",{inner_stats["content-length"]:.2f}')
return "\n".join(rows)

# register our new routes and extended UI with the Locust web UI
Expand Down
2 changes: 1 addition & 1 deletion locust/contrib/fasthttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ def rest_(self, method, url, name=None, **kwargs) -> Generator[RestResponseConte
separator = "&" if "?" in url else "?"
if name is None:
name = url + separator + "_=..."
with self.rest(method, f"{url}{separator}_={int(time.time()*1000)}", name=name, **kwargs) as resp:
with self.rest(method, f"{url}{separator}_={int(time.time() * 1000)}", name=name, **kwargs) as resp:
yield resp


Expand Down
6 changes: 3 additions & 3 deletions locust/runners.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ def spawn(user_class: str, spawn_count: int) -> list[User]:
new_users: list[User] = []
while n < spawn_count:
new_user = self.user_classes_by_name[user_class](self.environment)
assert hasattr(
new_user, "environment"
), f"Attribute 'environment' is missing on user {user_class}. Perhaps you defined your own __init__ and forgot to call the base constructor? (super().__init__(*args, **kwargs))"
assert hasattr(new_user, "environment"), (
f"Attribute 'environment' is missing on user {user_class}. Perhaps you defined your own __init__ and forgot to call the base constructor? (super().__init__(*args, **kwargs))"
)
new_user.start(self.user_greenlets)
new_users.append(new_user)
n += 1
Expand Down
11 changes: 4 additions & 7 deletions locust/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -827,7 +827,7 @@ def get_stats_summary(stats: RequestStats, current=True) -> list[str]:
("%-" + str(STATS_TYPE_WIDTH) + "s %-" + str(name_column_width) + "s %7s %12s |%7s %7s %7s%7s | %7s %11s")
% ("Type", "Name", "# reqs", "# fails", "Avg", "Min", "Max", "Med", "req/s", "failures/s")
)
separator = f'{"-" * STATS_TYPE_WIDTH}|{"-" * (name_column_width)}|{"-" * 7}|{"-" * 13}|{"-" * 7}|{"-" * 7}|{"-" * 7}|{"-" * 7}|{"-" * 8}|{"-" * 11}'
separator = f"{'-' * STATS_TYPE_WIDTH}|{'-' * (name_column_width)}|{'-' * 7}|{'-' * 13}|{'-' * 7}|{'-' * 7}|{'-' * 7}|{'-' * 7}|{'-' * 8}|{'-' * 11}"
summary.append(separator)
for key in sorted(stats.entries.keys()):
r = stats.entries[key]
Expand All @@ -850,14 +850,11 @@ def get_percentile_stats_summary(stats: RequestStats) -> list[str]:
summary = ["Response time percentiles (approximated)"]
headers = ("Type", "Name") + tuple(get_readable_percentiles(PERCENTILES_TO_REPORT)) + ("# reqs",)
summary.append(
(
f"%-{str(STATS_TYPE_WIDTH)}s %-{str(STATS_NAME_WIDTH)}s %8s "
f"{' '.join(['%6s'] * len(PERCENTILES_TO_REPORT))}"
)
(f"%-{str(STATS_TYPE_WIDTH)}s %-{str(STATS_NAME_WIDTH)}s %8s {' '.join(['%6s'] * len(PERCENTILES_TO_REPORT))}")
% headers
)
separator = (
f'{"-" * STATS_TYPE_WIDTH}|{"-" * STATS_NAME_WIDTH}|{"-" * 8}|{("-" * 6 + "|") * len(PERCENTILES_TO_REPORT)}'
f"{'-' * STATS_TYPE_WIDTH}|{'-' * STATS_NAME_WIDTH}|{'-' * 8}|{('-' * 6 + '|') * len(PERCENTILES_TO_REPORT)}"
)[:-1]
summary.append(separator)
for key in sorted(stats.entries.keys()):
Expand All @@ -880,7 +877,7 @@ def print_error_report(stats: RequestStats) -> None:
def get_error_report_summary(stats) -> list[str]:
summary = ["Error report"]
summary.append("%-18s %-100s" % ("# occurrences", "Error"))
separator = f'{"-" * 18}|{"-" * ((80 + STATS_NAME_WIDTH) - 19)}'
separator = f"{'-' * 18}|{'-' * ((80 + STATS_NAME_WIDTH) - 19)}"
summary.append(separator)
for error in stats.errors.values():
summary.append("%-18i %-100s" % (error.occurrences, error.to_name()))
Expand Down
7 changes: 4 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ test = [
]
lint = [
"pre-commit>=3.7.1,<4.0.0",
"ruff==0.7.3",
"ruff==0.10.0",
"mypy>=1.13.0,<2.0.0",
"types-requests>=2.32.0.20240622,<3.0.0",
]
Expand Down Expand Up @@ -132,8 +132,9 @@ extend-exclude = [
"examples/issue_*.py",
"src/readthedocs-sphinx-search/",
]
lint.ignore = ["E402", "E501", "E713", "E731", "E741"]
lint.ignore = ["E402", "E501", "E713", "E731", "E741", "UP031"]
lint.select = ["E", "F", "W", "UP", "FA102", "I001"]
lint.dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?)|resp)$"

[tool.ruff.lint.per-file-ignores]
"examples/*" = ["F841"]
Expand Down Expand Up @@ -233,7 +234,7 @@ python = ["3.12"]
[tool.hatch.envs.lint]
detached = true
dependencies = [
"ruff==0.7.3",
"ruff==0.10.0",
"mypy>=1.13.0,<2.0.0",
"types-requests>=2.32.0.20240622,<3.0.0",
]
Expand Down
Loading