-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationsgood first issueGood for newcomersGood for newcomershelp wantedContributions especially welcomeContributions especially welcome
Description
I think it applies to all error codes, but let me give an example where I encountered that.
Consider:
data = do_some_transformations()
return dataWhich 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 objectWhile I believe it should have been:
- return data # noqa: RET504 - to be able to debug the returned object
+ return dataAs 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationsgood first issueGood for newcomersGood for newcomershelp wantedContributions especially welcomeContributions especially welcome