Skip to content

Fix list-argument fallthrough in is_conjunction/is_prefix#214

Merged
derek73 merged 2 commits into
masterfrom
fix/pylance-list-argument-fallthrough
Jul 5, 2026
Merged

Fix list-argument fallthrough in is_conjunction/is_prefix#214
derek73 merged 2 commits into
masterfrom
fix/pylance-list-argument-fallthrough

Conversation

@derek73

@derek73 derek73 commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • A previous pylance-warning cleanup collapsed the if isinstance(piece, list): ... else: ... structure in is_conjunction/is_prefix into a bare fall-through return, which called .lower()/lc() on a list whenever a passed-in list had no matching item, raising AttributeError.
  • Adds the missing return False after the loop in both methods, matching the pattern already present in is_suffix.
  • Incidental: normalizes a stray single-quote to double-quotes in fix_phd (no behavior change).
  • Adds regression tests covering the no-match-list case for is_conjunction, is_prefix, and is_suffix, plus a missing matching-list test for is_suffix. The prior list tests only covered lists containing a match, so they never exercised the fall-through path that raised AttributeError.

Test plan

  • hn.is_prefix(['firstname', 'lastname']) and hn.is_conjunction(['firstname', 'lastname']) (no match) now return False instead of raising
  • New tests: test_is_prefix_with_list_no_match, test_is_conjunction_with_list_no_match, test_is_suffix_with_list, test_is_suffix_with_list_no_match
  • Existing list-match cases (test_is_prefix_with_list, test_is_conjunction_with_list) still pass
  • Full test suite: pytest tests/ — 1268 passed, 4 skipped, 22 xfailed

…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.
@derek73 derek73 self-assigned this Jul 5, 2026
@derek73 derek73 added the bug label Jul 5, 2026
@derek73 derek73 added this to the v1.3.0 milestone Jul 5, 2026
…through

Previous list-argument tests only covered lists containing a match, so they
never exercised the no-match fall-through path that raised AttributeError.
@derek73 derek73 merged commit 218f7e8 into master Jul 5, 2026
8 checks passed
@derek73 derek73 deleted the fix/pylance-list-argument-fallthrough branch July 5, 2026 01:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant