-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationshelp wantedContributions especially welcomeContributions especially welcome
Description
Summary
RET501 can delete comments if they are inside parenthesis with the None, in which case the comments should be moved, the fix should be unsafe, or the fix should not apply. playground
PS ~\Desktop\New_folder>Get-Content issue.py
def foo(bar):
if not bar:
return
return (
None # comment
)PS ~\Desktop\New_folder>uvx ruff check issue.py --isolated --select RET
issue.py:4:5: RET501 [*] Do not explicitly `return None` in function if it is the only possible return value
|
2 | if not bar:
3 | return
4 | / return (
5 | | None # comment
6 | | )
| |_____^ RET501
|
= help: Remove explicit `return None`
Found 1 error.
[*] 1 fixable with the `--fix` option.
PS ~\Desktop\New_folder>uvx ruff check issue.py --isolated --select RET --fix --diff
--- issue.py
+++ issue.py
@@ -1,6 +1,4 @@
def foo(bar):
if not bar:
return
- return (
- None # comment
- )
+ return
Would fix 1 error.Version
ruff 0.12.0 (87f0feb 2025-06-17) + playground
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingfixesRelated to suggested fixes for violationsRelated to suggested fixes for violationshelp wantedContributions especially welcomeContributions especially welcome