You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix shared-CONSTANTS state leaks in doctests, wire up doctest CI
Several docstring/doc examples mutated the shared CONSTANTS singleton
(capitalize_name, force_mixed_case_capitalization, empty_attribute_default,
titles.clear()) without resetting it. Since Sphinx's doctest groups only
isolate local variables, not global state, these leaked forward into later
examples across the whole doc build in an order-dependent way -- causing
wrong capitalization in the nicknames example, as_dict() returning None,
"Sir" leaking into first_list once titles was cleared, and more.
- nameparser/config/__init__.py: reset CONSTANTS after each docstring demo;
make SetManager.__repr__ sort elements so it's deterministic across
processes (previously relied on set() iteration order, which varies with
string hash randomization)
- docs/usage.rst: reset CONSTANTS.capitalize_name /
force_mixed_case_capitalization after their demo blocks
- docs/customize.rst: switch the "Hon" removal/clear-titles demo to a
local Constants() instance instead of the shared singleton (it isn't
actually demonstrating shared-singleton behavior, so there's no need to
mutate global state); fix the emoji example to call str(hn) instead of
showing hn's repr; update the SetManager ellipsis examples to match the
now-sorted repr
All 186 Sphinx doctests and the 10 README.rst doctests now pass (previously
multiple failures across usage.rst, customize.rst, and parser.py's own
docstrings). Wired both into CI (.github/workflows/python-package.yml) so
this doesn't silently regress again.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
0 commit comments