Skip to content

chore(python): bump ruff to 0.15.12 and apply format#2145

Open
mvanhorn wants to merge 3 commits into
vllm-project:mainfrom
mvanhorn:osc/2143-bump-ruff
Open

chore(python): bump ruff to 0.15.12 and apply format#2145
mvanhorn wants to merge 3 commits into
vllm-project:mainfrom
mvanhorn:osc/2143-bump-ruff

Conversation

@mvanhorn
Copy link
Copy Markdown

Closes #2143.

Bumps ruff from 0.6.1 (mid 2024) to 0.15.12 (latest) and applies ruff format so the formatter check is in sync with the new version.

Changes

  • python/aibrix/pyproject.toml: ruff = "0.6.1" -> ruff = "0.15.12".
  • python/aibrix/poetry.lock: regenerated to lock ruff at 0.15.12. Generated with poetry 1.8.5 (lockfile header). The non-ruff diff is two reordered marker lists (uvloop, pandas numpy) — the resolved versions are identical.
  • 13 files reformatted by ruff format. Each file is the exact set listed in the issue body. Diffs are formatter-only — ast.parse confirms identical ASTs before and after.

Verification

From python/aibrix/:

python -m ruff check .         # All checks passed!
python -m ruff format --check . # 169 files already formatted

Both gates from .github/workflows/python-aibrix-tests.yml pass cleanly with the new pin.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the ruff linter to version 0.15.12 and includes widespread reformatting of assert statements across the codebase, likely triggered by the linter update. Feedback focuses on the use of assert for runtime validation in production logic; it is recommended to replace these with explicit exceptions like RuntimeError or ValueError to prevent them from being optimized away in production environments.

Comment on lines +334 to +336
assert self.driver is not None, (
"Driver must be initialized before executing jobs"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using assert for runtime state validation in production code is discouraged because assertions can be disabled globally in Python (using the -O flag). If self.driver is None, it is better to raise an explicit exception like RuntimeError to ensure the check is always performed and provides a clear error message.

        if self.driver is None:
            raise RuntimeError("Driver must be initialized before executing jobs")

Comment on lines +393 to +395
assert self.driver is not None, (
"Driver must be initialized before waiting for jobs"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using assert for runtime state validation in production code is discouraged because assertions can be disabled globally in Python (using the -O flag). If self.driver is None, it is better to raise an explicit exception like RuntimeError to ensure the check is always performed and provides a clear error message.

        if self.driver is None:
            raise RuntimeError("Driver must be initialized before waiting for jobs")

Comment on lines +443 to +445
assert self.health_checker is not None, (
"Health checker should be initialized"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using assert for runtime state validation in production code is discouraged because assertions can be disabled globally in Python (using the -O flag). If self.health_checker is None, it is better to raise an explicit exception like RuntimeError to ensure the check is always performed and provides a clear error message.

            if self.health_checker is None:
                raise RuntimeError("Health checker should be initialized")

Comment on lines +571 to +573
assert job_status.in_progress_at is not None, (
"AssertError: Job must be set as in progress before setting as ready"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using assert for state validation in production logic is risky because it can be optimized away. Consider raising a ValueError or a custom exception instead to ensure the check is always executed.

        if job_status.in_progress_at is None:
            raise ValueError("Job must be set as in progress before setting as ready")

Comment on lines +39 to +41
assert metric.name == self.original_name, (
f"Metric name {metric.name} does not match Rule original name {self.original_name}"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using assert for validating input parameters or state in production code is not recommended. If the condition fails, it is better to raise a ValueError with a descriptive message to ensure the error is caught even in optimized environments.

Suggested change
assert metric.name == self.original_name, (
f"Metric name {metric.name} does not match Rule original name {self.original_name}"
)
if metric.name != self.original_name:
raise ValueError(
f"Metric name {metric.name} does not match Rule original name {self.original_name}"
)

Comment on lines +67 to +69
assert metric.name == self.metric_name, (
f"Metric name {metric.name} does not match Rule metric name {self.metric_name}"
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Using assert for validating input parameters or state in production code is not recommended. If the condition fails, it is better to raise a ValueError with a descriptive message to ensure the error is caught even in optimized environments.

Suggested change
assert metric.name == self.metric_name, (
f"Metric name {metric.name} does not match Rule metric name {self.metric_name}"
)
if metric.name != self.metric_name:
raise ValueError(
f"Metric name {metric.name} does not match Rule metric name {self.metric_name}"
)

@varungup90
Copy link
Copy Markdown
Collaborator

can you sign the PR.

Copy link
Copy Markdown
Collaborator

@Jeffwan Jeffwan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall looks good to me. we make lots of changes to poetry recently, please rebase the master to fetch the latest code

@Jeffwan
Copy link
Copy Markdown
Collaborator

Jeffwan commented May 5, 2026

@mvanhorn could you help regenerate the lock file using higher poetry version

 This file is automatically @generated by Poetry 2.1.2 and should not be changed by hand

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bump ruff==0.6.1 to latest version

3 participants