Skip to content

Change CLI to respect Applicability #4185

@MichaReiser

Description

@MichaReiser

This task is part of #4181 and depends on #4183. The goal is to change the CLI to respect the Fix::applicability.

  • Change --fix to only apply Applicability::Safe fixes. Print a message with the number of fixes that were skipped because they have an Applicability other than Safe and print the number at the end.
  • Add a new --fix-unsafe CLI option that applies all fixes
  • Change --diff and --fix-only to imply --fix but runs all fixes if the user also provides --fix-unsafe.

Considerations

  • We may want to hold off with this change until we've categorized a significant part of the fixes (see Categorise fixes as safe or maybe_incorrect #4184).
  • I recommend introducing a new --fix-unsafe to apply unsafe fixes of past experience at Rome. Rome used to apply all fixes with --fix but we got multiple reports from users that they did not expect Rome to make changes that may change the program's semantic. That's why we decided to rename the CLI option to --apply and --apply-unsafe to make it clear, that the latter applies fixes that may be incorrect. The downside of not running all fixes with --fix is that I expect that some users may be confused why ruff doesn't apply all fixes when running --fix.

Metadata

Metadata

Labels

breakingBreaking API changecliRelated to the command-line interfacehelp wantedContributions especially welcome

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions