Skip to content

Policy for linter fixes that can drop comments #9790

@zanieb

Description

@zanieb

In some cases, a lint fix can drop comments. Retaining all comments was a major goal in the Ruff formatter and we've learned that it is very hard to accomplish. There is significant foundational work that would need to be invested in the linter to prevent it from ever dropping comments. While we would like to accomplish this eventually, we're a small team with a lot of priorities to balance. In the meantime, we want to formalize a policy for fixes that may drop comments.

A few options:

  1. A fix should not be offered if the range contains a comment
  2. A fix that may drop a comment must always be unsafe
  3. A fix that may drop a comment must be unsafe if a comment is present in the fix range
  4. A fix will only drop comments in ranges that use dangerous syntax e.g. line continuations
  5. A fix that may drop a comment is always safe — we do not make guarantees about comments

We currently apply a mix of these options, but we should be consistent. More options and discussion welcome.

Related issues and reports:

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixesRelated to suggested fixes for violations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions