Skip to content
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

[ruff] Fix --statistics reporting for unsafe fixes #16756

Merged

Conversation

ZedThree
Copy link
Contributor

Fixes #16751

Summary

Previously, unsafe fixes were counted as "fixable" in Printer::write_statistics, in contrast to the behaviour in Printer::write_once. This changes the behaviour to align with write_once, including them only if --unsafe-fixes is set.

We now also reuse Printer::write_summary to avoid duplicating the logic for whether or not to report if there are hidden fixes.

Test Plan

Existing tests modified to use an unsafe-fixable rule, and new ones added to cover the case with --unsafe-fixes

Fixes astral-sh#16751

Previously, unsafe fixes were counted as "fixable" in
`Printer::write_statistics`, in contrast to the behaviour in
`Printer::write_once`. This changes the behaviour to align with
`write_once`, including them only if `--unsafe-fixes` is set.

We now also reuse `Printer::write_summary` to avoid duplicating the
logic for whether or not to report if there are hidden fixes.
Copy link
Contributor

ruff-ecosystem results

Linter (stable)

✅ ecosystem check detected no linter changes.

Linter (preview)

✅ ecosystem check detected no linter changes.

Copy link
Member

@MichaReiser MichaReiser left a comment

Choose a reason for hiding this comment

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

That makes sense. Thank you

@MichaReiser MichaReiser added bug Something isn't working cli Related to the command-line interface labels Mar 18, 2025
@MichaReiser MichaReiser merged commit 433879d into astral-sh:main Mar 18, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working cli Related to the command-line interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ruff check --statistics shows unsafe fixes as fixable
2 participants