Fix IndexError in initials for unnormalized *_list elements#236
Merged
Conversation
_process_initial split name parts with split(" "), which yields empty
strings for repeated spaces, and part[0] on an empty string raised
IndexError. The parse path never produces such parts because
parse_pieces normalizes whitespace, but first_list/middle_list/
last_list are plain attributes, so direct assignment bypasses that
normalization (e.g. name.middle_list = ['Q R']).
Use bare split(), which treats any whitespace run as one delimiter and
never yields empty strings — identical to split(" ") for normalized
input, and also tolerant of tabs, newlines, and leading/trailing
whitespace in directly-assigned elements.
Closes #232
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #236 +/- ##
=======================================
Coverage 97.25% 97.25%
=======================================
Files 13 13
Lines 802 802
=======================================
Hits 780 780
Misses 22 22 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Summary
_process_initialsplit name parts withsplit(" "), so an element containing a doubled space (e.g.name.middle_list = ['Q R']) produced an empty-string part andpart[0]raisedIndexError(closes IndexError in initials_list() when a *_list attribute contains a doubled-space element #232)*_listattributes hits this — the normal constructor/property paths go throughparse_pieces, which normalizes whitespace before elements reach the initials codesplit(): identical tosplit(" ")for normalized input, never yields empty strings, and also tolerates tabs/newlines/leading/trailing whitespace; whitespace-only elements now yield no initials and are dropped by the existing caller-side filterTest plan
IndexErrorfrom the issue before the fix, asserting the doubled-space element produces the same initials as its single-space equivalent🤖 Generated with Claude Code