-
Notifications
You must be signed in to change notification settings - Fork 2k
Closed
Labels
questionAsking for support or clarificationAsking for support or clarification
Description
I have searched SIM103 in the open issues and didn't find anything related, so creating this one.
It seems the error message/prompt for SIM103 can be incorrect in some cases.
My code base is quite large, but if I copy the single function out for testing, I could not reproduce. It only happens on the large code base:
lint: commands[0]> ruff check --preview
ops/testing.py:3469:9: SIM103 Return the condition `keys is not None and notice.key not in keys` directly
|
3467 | if types is not None and notice.type not in types:
3468 | return False
3469 | if keys is not None and notice.key not in keys:
| _________^
3470 | | return False
3471 | | return True
| |___________________^ SIM103
|
= help: Inline condition
Found 1 error.
No fixes available (1 hidden fix can be enabled with the `--unsafe-fixes` option).I think the prompt/error message is not correct. How could:
if condition:
return False
return True
be replaced by return condition? The message should be something like "return not condition instead", not "return condition instead". If the user copy/paste the suggestion it'd be wrong.
Only
if condition:
return True
return False
can be replaced directly by return condition instead.
With latest ruff version 0.3.5.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
questionAsking for support or clarificationAsking for support or clarification