ruff
beec2f2d - [`flake8-simplify`] Improve help message clarity (`SIM105`) (#20548)

Commit
1 day ago
[`flake8-simplify`] Improve help message clarity (`SIM105`) (#20548) ## Summary Improve the SIM105 rule message to prevent user confusion about how to properly use `contextlib.suppress`. The previous message "Replace with `contextlib.suppress(ValueError)`" was ambiguous and led users to incorrectly use `contextlib.suppress(ValueError)` as a statement inside except blocks instead of replacing the entire try-except-pass block with `with contextlib.suppress(ValueError):`. This change makes the message more explicit: - **Before**: `"Use \`contextlib.suppress({exception})\` instead of \`try\`-\`except\`-\`pass\`"` - **After**: `"Replace \`try\`-\`except\`-\`pass\` block with \`with contextlib.suppress({exception})\`"` The fix title is also updated to be more specific: - **Before**: `"Replace with \`contextlib.suppress({exception})\`"` - **After**: `"Replace \`try\`-\`except\`-\`pass\` with \`with contextlib.suppress({exception})\`"` Fixes #20462 ## Test Plan - ✅ All existing SIM105 tests pass with updated snapshots - ✅ Cargo clippy passes without warnings - ✅ Full test suite passes - ✅ The new messages clearly indicate that the entire try-except-pass block should be replaced with a `with` statement, preventing the misuse described in the issue --------- Co-authored-by: Giovani Moutinho <e@mgiovani.dev>
Author
Parents
Loading