Give Constants a useful __repr__#221
Merged
Merged
Conversation
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.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
- 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Constants.__repr__'s uninformative<Constants() instance>with a bracketed multi-line repr (matchingHumanName's style) that reports collection sizes (prefixes,titles, etc.) and any scalar config flags that differ from their class default.docs/customize.rstthat asserted the old repr string, using+ELLIPSISso they don't need updating every time a config set's size changes.ConstantsReprTestsintests/test_constants.pycovering: 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 xfaileduv run sphinx-build -b doctest docs dist/doctest— 186 passed, 0 failed🤖 Generated with Claude Code