-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
Fixed #36519 -- Made centre filter consistent for odd padding. #19669
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
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.
Hello! Thank you for your contribution 💪
As it's your first contribution be sure to check out the patch review checklist.
If you're fixing a ticket from Trac make sure to set the "Has patch" flag and include a link to this PR in the ticket!
If you have any design or process questions then you can ask in the Django forum.
Welcome aboard ⛵️!
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.
Thank you @mriduldhall for this branch! 🌟
The core of the solution is correct. I was thinking that we could use some extra testing for the center
template filter as an initial commit, to ensure that behavior is not changed (other than for the fix itself).
For example, I think that the current center
in main
accepts negative values while this version does not. How about adding this new test which passes in main
?
def test_widths(self):
value = "something"
for i in (-1, *range(len(value) + 1)):
with self.subTest(i=i):
self.assertEqual(center(value, i), value)
In summary, ideally this PR would include two commits, the first one with the test above and the second one with the actual ticket fix (and something will have to be done for negative widths).
Hi @nessita, As per your suggested changes what would the ideal next steps be for me? Should I add commits to the current branch and PR or would it be a better idea to close this PR and create a new PR? |
You can make the changes on this branch. |
@mriduldhall For nessita's suggestion to have the test she suggested in its own commit, you might find it useful to look into how |
f93d96c
to
78c8705
Compare
Thank you for the guidance! Would the commits now be in a suitable form? |
78c8705
to
a8214f8
Compare
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.
Thank you @mriduldhall for addressing my review comments.
I think there’s still a small misunderstanding. The first commit, taken on its own, doesn't have a passing test suite (test_even_input
fails). We need to make sure that the tests pass both after the first and second commits.
My original suggestion was to add only the test_widths
test in the first commit (which should pass with the current logic), and then include the full set of changes that fix ticket-36519 in the second commit (this would be the logic change and test_odd_input
and test_even_input
).
Lastly, the first commit could be something like this:
Added test for various widths in tests/template_tests/filter_tests/test_center.py.
I'm happy to help rearrange the commits if needed, but feel free to give it a shot, just let me know!
a8214f8
to
483606f
Compare
I believe the commits should now be in the required form. |
Amazing, thank you @mriduldhall and @LilyAcorn, this looks good, I will do the final review and merge next week. Well done! 🌟 |
…adding. Refactored `center` template filter to match f-string behaviour, producing consistent padding for both odd and even fillings. Thanks Lily Acorn for the report and Natalia Bidart for the review. Co-authored-by: Lily Acorn <[email protected]>
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.
Looks great, thank you! Will merge when CI is green 🌟
(I pushed a small fix of the commit messages since the filter is called center
and not centre
.)
Refactored template centre filter to match f-string behaviour for filter.
Thanks Lily Acorn for the report.
Trac ticket number
ticket-36519
Branch description
Provide a concise overview of the issue or rationale behind the proposed changes.
Checklist
main
branch.