Skip to content

Commit 1bfbbe4

Browse files
committed
Extract leading_first_name from bundled guard condition
Code review noted the compound condition conflated "is this piece a prefix candidate at all" with "is it exempted as a leading first name" into one boolean expression. Name the second clause so its rationale is legible at the call site.
1 parent a5aff94 commit 1bfbbe4

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

nameparser/parser.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,10 +1306,10 @@ def shift_conj_index(past: int, by: int) -> None:
13061306
# join prefixes to following lastnames: ['de la Vega'], ['van Buren']
13071307
i = 0
13081308
while i < len(pieces):
1309-
if not self.is_prefix(pieces[i]) or (i == 0 and total_length >= 1):
1310-
# If it's the first piece and there's at least 1 rootname
1311-
# elsewhere, assume this piece is a first name rather than a
1312-
# prefix (total_length >= 1 covers essentially all real input).
1309+
# total_length >= 1 covers essentially all real input, so this
1310+
# treats any leading piece as a first name rather than a prefix.
1311+
leading_first_name = i == 0 and total_length >= 1
1312+
if not self.is_prefix(pieces[i]) or leading_first_name:
13131313
i += 1
13141314
continue
13151315

0 commit comments

Comments
 (0)