Skip to content

Commit 9ca29f3

Browse files
derek73claude
andcommitted
Remove default values from class-level list annotations
Using = [] on class-level attributes creates a single shared list instance across all HumanName instances. Any direct mutation (e.g. hn.first_list.append(...)) on an instance created without a full_name would corrupt the default for all subsequent instances. Both code paths in __init__ (parse_full_name and the per-attribute setters) always initialize these as instance-level lists, so the class-level defaults were never needed — only the type annotations are. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent b3efc25 commit 9ca29f3

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

nameparser/parser.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,12 @@ class HumanName:
8282
unparsable = True
8383
_full_name = ''
8484

85-
title_list: list[str] = []
86-
first_list: list[str] = []
87-
middle_list: list[str] = []
88-
last_list: list[str] = []
89-
suffix_list: list[str] = []
90-
nickname_list: list[str] = []
85+
title_list: list[str]
86+
first_list: list[str]
87+
middle_list: list[str]
88+
last_list: list[str]
89+
suffix_list: list[str]
90+
nickname_list: list[str]
9191

9292
def __init__(
9393
self,

0 commit comments

Comments
 (0)