Title: Remove empty_attribute_default; empty attributes always return '' · Issue #255 · derek73/python-nameparser · GitHub
Open Graph Title: Remove empty_attribute_default; empty attributes always return '' · Issue #255 · derek73/python-nameparser
X Title: Remove empty_attribute_default; empty attributes always return '' · Issue #255 · derek73/python-nameparser
Description: Summary 2.0 removes the empty_attribute_default config option entirely. Empty name attributes always return ''. Once None support goes (see below for why it must), the only legal value left is the default — a dial with one position isn't...
Open Graph Description: Summary 2.0 removes the empty_attribute_default config option entirely. Empty name attributes always return ''. Once None support goes (see below for why it must), the only legal value left is the ...
X Description: Summary 2.0 removes the empty_attribute_default config option entirely. Empty name attributes always return ''. Once None support goes (see below for why it must), the only legal value left...
Opengraph URL: https://github.com/derek73/python-nameparser/issues/255
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Remove empty_attribute_default; empty attributes always return ''","articleBody":"## Summary\n\n2.0 removes the `empty_attribute_default` config option entirely. Empty name attributes always return `''`. Once `None` support goes (see below for why it must), the only legal value left is the default — a dial with one position isn't configuration.\n\n## History: why it exists\n\nAdded in v0.3.15 (2016, pre-1.0) for #44: a user wanted `None` instead of `''` to store name components as database `NULL`s. The maintainer's first response was the one-liner that is now the migration path — \"you could do it easily too with something like `name.title or None`\" — and \"I don't have a strong preference.\" Making `None` the universal return broke the formatting tests, so a config option was added as a compromise. The first consequence arrived in the same thread: `str()` produced `'None John None Doe None (None)'`, patched in PR #45 with a `.replace(str(empty_attribute_default), '')` scrub that is still in `__str__` today.\n\n## What it has cost\n\n- Every `-\u003e str` annotation on the public API is false when the option is set to `None`; the attribute was deliberately left untyped in the mypy work (PR #250) because typing it honestly cascades `| None` through everything\n- The `\"J. None D.\"` initials bug, fixed in 1.3.0 — same laundering class\n- **Live data corruption** (#254): the PR #45 scrub can't distinguish an interpolated `None` from name text, so in None-mode `str(HumanName(\"Nonez Smith\"))` returns `'z Smith'` — the parse is correct and `__str__` strips the literal `None` out of the person's name\n\n## What removal deletes\n\nThe `or self.C.empty_attribute_default` tail on all seven attribute properties plus `surnames`/`given_names`/`last_base`/`last_prefixes` and `initials()`; the `__str__` scrub hack; the docs section; the test `type: ignore`s.\n\n## Removal mechanics (both learned from the 1.3.0 guard work)\n\n- **Tombstone, not deletion:** `empty_attribute_default` is a plain attribute, so naive removal makes `CONSTANTS.empty_attribute_default = None` a silent no-op — the accept-and-ignore failure family #241 exterminated. 2.0 keeps a property whose setter raises with the migration hint.\n- **Readers exist, not just writers:** the #44 thread advised asserting against `hn.C.empty_attribute_default` in downstream tests. Reads break loudly with the tombstone; migration is \"compare with `''` or truthiness.\"\n\n## Migration\n\n`hn.first or None` at the database boundary, or `{k: v or None for k, v in name.as_dict().items()}` for a whole record.\n\n## Bridge (1.4) — tracked in #263\n\n- [ ] `DeprecationWarning` on any assignment to `empty_attribute_default`\n- [ ] Ship the `__str__` mangling fix (#254) so None-mode users get correct output during their migration window\n\n","author":{"url":"https://github.com/derek73","@type":"Person","name":"derek73"},"datePublished":"2026-07-06T07:44:41.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/255/python-nameparser/issues/255"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:ac422f81-da57-a2f8-23b4-f9e65d1263d9 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A71E:3AEA05:C470D3:10C770E:6A555F61 |
| html-safe-nonce | 4e9ac235a21a516a281e72dc474c4f1e08bc47d66c29b75bb60b33a10d845c7e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzFFOjNBRUEwNTpDNDcwRDM6MTBDNzcwRTo2QTU1NUY2MSIsInZpc2l0b3JfaWQiOiI1NjQ5MDk3NjM0OTc3NTA1MTIyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 6c682e9a8a601c5599387a5e4102bd02938668db9ebe109e2791282c65be624a |
| hovercard-subject-tag | issue:4817041778 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/derek73/python-nameparser/255/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4c0db5d7726eb38dea925672f5acf1a64d84ab0ea2373b96148bf1a262636e61/derek73/python-nameparser/issues/255 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4c0db5d7726eb38dea925672f5acf1a64d84ab0ea2373b96148bf1a262636e61/derek73/python-nameparser/issues/255 |
| og:image:alt | Summary 2.0 removes the empty_attribute_default config option entirely. Empty name attributes always return ''. Once None support goes (see below for why it must), the only legal value left is the ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | derek73 |
| hostname | github.com |
| expected-hostname | github.com |
| None | b5665c84831ed9ac4fb79519c16c9c5580ba8092fb8bb6e3e72972ec7197348e |
| turbo-cache-control | no-preview |
| go-import | github.com/derek73/python-nameparser git https://github.com/derek73/python-nameparser.git |
| octolytics-dimension-user_id | 18306 |
| octolytics-dimension-user_login | derek73 |
| octolytics-dimension-repository_id | 18353524 |
| octolytics-dimension-repository_nwo | derek73/python-nameparser |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 18353524 |
| octolytics-dimension-repository_network_root_nwo | derek73/python-nameparser |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 73595e82546ca2415571a2031890ab16ecb3001a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width