Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIM105 should not autofix when not an exception (B030) #5977

Closed
sbrugman opened this issue Jul 22, 2023 · 0 comments · Fixed by #5985
Closed

SIM105 should not autofix when not an exception (B030) #5977

sbrugman opened this issue Jul 22, 2023 · 0 comments · Fixed by #5985
Labels
accepted Ready for implementation bug Something isn't working

Comments

@sbrugman
Copy link
Contributor

sbrugman commented Jul 22, 2023

try:
    ...
except ("not", "an", "exception"):
    pass

Detects the SIM105 and B030 violations.
If the SIM105 fix is applied, then B030 is lost:

import contextlib

with contextlib.suppress(Exception):
    print()

I think we should not autofix SIM105 here, similar to refurb.

Links:

(Thanks to @dosisod for flagging here)

@charliermarsh charliermarsh added bug Something isn't working accepted Ready for implementation labels Jul 22, 2023
sbrugman added a commit to sbrugman/ruff that referenced this issue Jul 22, 2023
charliermarsh pushed a commit that referenced this issue Jul 22, 2023
Closes #5977

Added a test case from `refurb`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
accepted Ready for implementation bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants