fix(filters): do not append fill_with when items divide evenly across slices#2154
Closed
justDance-everybody wants to merge 4 commits intopallets:mainfrom
Closed
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes slice filter behavior in Jinja2 so that fill_with is not appended when the input length divides evenly across the requested number of slices.
Changes:
- Update
sync_do_sliceto only appendfill_withwhen there is a remainder (slices_with_extra > 0) and the current slice is one of the shorter slices.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1092
to
+1093
| if ( | ||
| fill_with is not None |
There was a problem hiding this comment.
Please add a regression test for the case where the input length divides evenly by the number of slices (so slices_with_extra == 0). With fill_with provided, this should not append any filler items (e.g., range(9)|slice(3, 'X') should yield [[0,1,2],[3,4,5],[6,7,8]]). This will ensure the bug fixed here doesn’t reappear, and should be covered in both sync and async filter tests if applicable.
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.
Fixes #2118 - see commit message for details