Fix str() scrubbing literal "None" from names when empty_attribute_default is None#277
Merged
Conversation
…fault is None
__str__ formatted the template with raw attribute values and then deleted
every occurrence of str(empty_attribute_default) from the result — a scrub
that couldn't distinguish the interpolated None from real name text
containing the same substring, so HumanName("Nonez Smith") rendered as
"z Smith" in None-mode. Substitute '' for falsy attributes before
str.format() instead, mirroring the initials() fix from 1.3.0, and delete
the scrub.
Closes #254
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #277 +/- ##
=======================================
Coverage 97.69% 97.69%
=======================================
Files 13 13
Lines 912 912
=======================================
Hits 891 891
Misses 21 21 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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
With
empty_attribute_default = None,__str__formatted the template with raw attribute values and then deleted every occurrence of"None"from the result — a scrub (dating to PR #45, 2016) that couldn't distinguish the interpolatedNonefrom real name text containing the same substring:The fix substitutes
''for falsy attributes beforestr.format()runs and deletes the scrub outright, mirroring howinitials()was fixed for the same bug family in 1.3.0. This also removes the latent corruption for any customempty_attribute_defaultstring (e.g."N/A") appearing in real name text.Closes #254
Testing
tests/test_output_format.py: a name containing"None"as a substring and a name piece that is exactlyNone(both watched failing with'z Smith'before the fix)1.3.1 - Unreleased🤖 Generated with Claude Code