Fix list-argument fallthrough in is_conjunction/is_prefix#214
Merged
Conversation
…ce cleanup A prior pylance-warning cleanup collapsed the if/else in is_conjunction and is_prefix, but left the list branch falling through into the scalar return when no item matched, calling piece.lower()/lc(piece) on a list and raising AttributeError. Add the explicit `return False` after the loop, matching the same pattern already used in is_suffix.
…through Previous list-argument tests only covered lists containing a match, so they never exercised the no-match fall-through path that raised AttributeError.
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
if isinstance(piece, list): ... else: ...structure inis_conjunction/is_prefixinto a bare fall-throughreturn, which called.lower()/lc()on alistwhenever a passed-in list had no matching item, raisingAttributeError.return Falseafter the loop in both methods, matching the pattern already present inis_suffix.fix_phd(no behavior change).is_conjunction,is_prefix, andis_suffix, plus a missing matching-list test foris_suffix. The prior list tests only covered lists containing a match, so they never exercised the fall-through path that raisedAttributeError.Test plan
hn.is_prefix(['firstname', 'lastname'])andhn.is_conjunction(['firstname', 'lastname'])(no match) now returnFalseinstead of raisingtest_is_prefix_with_list_no_match,test_is_conjunction_with_list_no_match,test_is_suffix_with_list,test_is_suffix_with_list_no_matchtest_is_prefix_with_list,test_is_conjunction_with_list) still passpytest tests/— 1268 passed, 4 skipped, 22 xfailed