Skip to content

Give Constants a useful __repr__#221

Merged
derek73 merged 2 commits into
masterfrom
feature/constants-repr
Jul 5, 2026
Merged

Give Constants a useful __repr__#221
derek73 merged 2 commits into
masterfrom
feature/constants-repr

Conversation

@derek73

@derek73 derek73 commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Summary

  • Replace Constants.__repr__'s uninformative <Constants() instance> with a bracketed multi-line repr (matching HumanName's style) that reports collection sizes (prefixes, titles, etc.) and any scalar config flags that differ from their class default.
  • Update the two doctests in docs/customize.rst that asserted the old repr string, using +ELLIPSIS so they don't need updating every time a config set's size changes.
  • Add ConstantsReprTests in tests/test_constants.py covering: accurate collection counts, omission of default-valued scalars, display of overridden scalars, reflecting mutated collection sizes, and the bracketed multi-line shape.

Test plan

  • python -m pytest -q — 1316 passed, 4 skipped, 22 xfailed
  • uv run sphinx-build -b doctest docs dist/doctest — 186 passed, 0 failed

🤖 Generated with Claude Code

The previous __repr__ ("<Constants() instance>") didn't identify which
instance you were looking at or how it differed from the default,
making it useless for debugging config state.

Collections (some with hundreds of entries, e.g. titles/prefixes) are
summarized as counts rather than dumped in full. Scalar config flags
are only shown when they differ from the class default, so a plain
Constants() reads as just the collection sizes. Formatted as a
bracketed multi-line block to match HumanName's __repr__ style.

Updates the two doctests in docs/customize.rst that asserted the old
repr string, using ELLIPSIS so they don't break every time a config
set's size changes.
@derek73 derek73 self-assigned this Jul 5, 2026
@derek73 derek73 added this to the v1.3.0 milestone Jul 5, 2026
@codecov-commenter

codecov-commenter commented Jul 5, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.25%. Comparing base (e518479) to head (173e951).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #221      +/-   ##
==========================================
+ Coverage   97.11%   97.25%   +0.13%     
==========================================
  Files          13       13              
  Lines         797      801       +4     
==========================================
+ Hits          774      779       +5     
+ Misses         23       22       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Add a release_log.rst bullet for the __repr__ change (#221)
- Fix the scalar-override test to exercise direct assignment, since 8 of
  the 10 tracked scalars aren't __init__ kwargs at all -- only
  patronymic_name_order and middle_name_as_last are
- Add tests for multiple simultaneous scalar overrides and an empty
  collection
@derek73 derek73 merged commit 016873c into master Jul 5, 2026
8 checks passed
@derek73 derek73 deleted the feature/constants-repr branch July 5, 2026 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants