Problem
Both names.py and voice.py use assert statements to validate genre coverage at import time. When Python runs with -O (optimize flag), all assert statements are compiled out.
# names.py lines 53-56
assert not _missing_name_genres, (...)
# voice.py lines 247-250
assert not _missing_voice_genres, (...)
Why It Matters
If someone adds a genre to ALLOWED_GENRES without adding mappings:
names.py returns the "contemporary" name pool (culturally inappropriate names)
voice.py produces unweighted random voice selection (no genre bias)
No error visible to the user.
Recommended Fix
Replace assertions with explicit if checks that raise ValueError:
_missing_name_genres = ALLOWED_GENRES - _GENRE_GROUP.keys()
if _missing_name_genres:
raise ValueError(f"Genres missing from _GENRE_GROUP: {sorted(_missing_name_genres)}")
Problem
Both
names.pyandvoice.pyuseassertstatements to validate genre coverage at import time. When Python runs with-O(optimize flag), allassertstatements are compiled out.Why It Matters
If someone adds a genre to
ALLOWED_GENRESwithout adding mappings:names.pyreturns the"contemporary"name pool (culturally inappropriate names)voice.pyproduces unweighted random voice selection (no genre bias)No error visible to the user.
Recommended Fix
Replace assertions with explicit
ifchecks that raiseValueError: