-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Python: Don't prune any MatchLiteralPatterns
#18738
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
Conversation
Extends the mechanism introduced in #18030 to behave the same for _all_ `MatchLiteralPattern`s, not just the ones that happen to be the constant `True` or `False`. Co-authored-by: yoff <yoff@github.com>
Co-authored-by: yoff <yoff@github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR Overview
This pull request extends the mechanism for pruning to ensure that no MatchLiteralPattern is ever pruned, avoiding the risk of misidentifying reachable code.
- The change notes have been updated to reflect the new behavior.
- The conditional check in the pruner for boolean literal patterns has been removed so that all MatchLiteralPatterns are processed uniformly.
Changes
| File | Description |
|---|---|
| python/ql/lib/change-notes/2025-02-11-fix-match-literal-pruning.md | Added notes to clarify that no MatchLiteralPattern is pruned |
| python/extractor/semmle/python/passes/pruner.py | Removed conditional pruning for boolean MatchLiteralPatterns to apply the fix universally |
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more
python/ql/lib/change-notes/2025-02-11-fix-match-literal-pruning.md
Outdated
Show resolved
Hide resolved
Co-authored-by: Aditya Sharad <6874315+adityasharad@users.noreply.github.com>
yoff
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Extends the mechanism introduced in #18030 to behave the same for all
MatchLiteralPatterns, not just the ones that happen to be the constantTrueorFalse.