[flake8-simplify] Suppress SIM105 for except* before Python 3.12#23869
Open
getehen wants to merge 2 commits intoastral-sh:mainfrom
Open
[flake8-simplify] Suppress SIM105 for except* before Python 3.12#23869getehen wants to merge 2 commits intoastral-sh:mainfrom
flake8-simplify] Suppress SIM105 for except* before Python 3.12#23869getehen wants to merge 2 commits intoastral-sh:mainfrom
Conversation
|
ntBre
requested changes
Mar 10, 2026
Contributor
ntBre
left a comment
There was a problem hiding this comment.
This fix doesn't appear to be correct. I checked the ecosystem report and regular except handlers (with just except) are no longer being flagged. The issue is specific to except* handlers like that shown in the issue:
def raise_group(x):
raise ExceptionGroup("!", [ValueError(x)])
try:
raise_group(1)
except* ValueError: # This needs to be skipped
pass
try: ...
except ValueError: # This should still emit a diagnostic
pass
Contributor
Author
|
My bad, I will look into it |
For py311, suppressible-exception should not be raised with except* (in my previous commit I disabled it with every except, independently of the *, which is wrong). New tests accordingly.
ntBre
reviewed
Mar 12, 2026
Contributor
ntBre
left a comment
There was a problem hiding this comment.
Thank you! This looks good to me now, I just had one suggestion about testing.
| Path::new("flake8_simplify").join(path).as_path(), | ||
| &settings::LinterSettings::for_rule(rule_code).with_target_version(py_version), | ||
| )?; | ||
| assert_diagnostics!(snapshot, diagnostics); |
Contributor
There was a problem hiding this comment.
I think this would be a good use of our assert_diagnostics_diff! macro instead of two separate test_cases.
flake8-simplify] Suppress SIM105 for except* before Python 3.12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi,
Fix 23798 : SIM105 should not be active before py 3.12.
The solution is simple: If the target version is lower or equal than 3.11, the check is passed.
There might be a caveat: I am not sure the target version is always 100% valid ? But it seemed the most accurate thing to use here.
Some tests were added, checking in 3.12 and 3.11 to check that the test suppression happen in 3.11 but not in 3.12.
I can also add a mention in the docs ? If so, should I do this directly here ?