[rejected AI] do not append fill_with in slice when slice count evenly divides iterable - #2260
Closed
pylrn wants to merge 1 commit into
Closed
[rejected AI] do not append fill_with in slice when slice count evenly divides iterable#2260pylrn wants to merge 1 commit into
pylrn wants to merge 1 commit into
Conversation
…y divides iterable
Member
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
Problem
When
slicesevenly divideslen(seq)(e.g.[1, 2, 3, 4]|slice(4, 'foo')),slices_with_extra = length % slicesis0.Because the check was
slice_number >= slices_with_extra, every slice satisfiedslice_number >= 0and hadfill_withappended, adding an extra unnecessary element to every sub-list even though all slices were already full and of equal length.Fix
fill_withcheck insync_do_sliceinsrc/jinja2/filters.pyto requireslices_with_extra > 0in addition toslice_number >= slices_with_extra.tests/test_filters.pyandtests/test_async_filters.py.