Fix potential-index-error false positive when iterable contains starred element#10097
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10097 +/- ##
=======================================
Coverage 95.80% 95.80%
=======================================
Files 174 174
Lines 18962 18973 +11
=======================================
+ Hits 18166 18177 +11
Misses 796 796
🚀 New features to boost your workflow:
|
This comment has been minimized.
This comment has been minimized.
d627b12 to
9e865b4
Compare
Contributor
|
🤖 According to the primer, this change has no effect on the checked open source code. 🤖🎉 This comment was generated for commit 9e865b4 |
Pierre-Sassoulas
approved these changes
Nov 24, 2024
Member
Pierre-Sassoulas
left a comment
There was a problem hiding this comment.
Looks great, thank you!
DanielNoord
approved these changes
Nov 24, 2024
Pierre-Sassoulas
pushed a commit
that referenced
this pull request
Nov 24, 2024
…rred element (#10097) (#10098) (cherry picked from commit 3e9e613) Co-authored-by: Zen Lee <[email protected]>
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.
Type of Changes
Description
The current implementation calculates the length of an indexed iterable by using its literal length. However, this approach fails when the iterable contains a starred element that unpacks into multiple elements.
For example:
This PR addresses the issue by extending the check to account for the inferred length of starred nodes within the indexed iterable.
Closes #10076