Skip to content

RUF100 should probably delete an entire comment noqa is part of #12251

@yury-fedotov

Description

@yury-fedotov

I think it applies to all error codes, but let me give an example where I encountered that.

Consider:

data = do_some_transformations()
return data

Which is a violation of RET504 - unnecessary assignment.

I needed to perform the assignment and return data, not return do_some_transformations(), so added a noqa: RET504 with explanation of why I want to bypass the rule:

data = do_some_transformations()
return data  # noqa: RET504 - to be able to debug the returned object.

Then I disabled RET504 in ruff config completely, and this noqa became unused. Here is where RUF100 comes into play, as it complains on unused error codes, and provides a fix.

The fix was:

-    return data  # noqa: RET504 - to be able to debug the returned object
+    return data  # - to be able to debug the returned object

While I believe it should have been:

-    return data  # noqa: RET504 - to be able to debug the returned object
+    return data

As it's probably quite safe to assume that entire content of the comment noqa is part of is explaining why a rule should by bypassed.

  • List of keywords you searched for before creating this issue: RUF100
  • Most similar open issue: RUF100 for noqa: E501 not at end of line #7851
  • A minimal code snippet that reproduces the bug: see above.
  • The command you invoked: ruff check --fix
  • The current Ruff version: 0.5.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixesRelated to suggested fixes for violationsgood first issueGood for newcomershelp wantedContributions especially welcome

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions