Title: Add Constants.copy(); deprecate constants=None · Issue #260 · derek73/python-nameparser · GitHub
Open Graph Title: Add Constants.copy(); deprecate constants=None · Issue #260 · derek73/python-nameparser
X Title: Add Constants.copy(); deprecate constants=None · Issue #260 · derek73/python-nameparser
Description: Summary constants=None means "construct a fresh private Constants()" — a sentinel that means the opposite of what None conventionally means (the default here is the shared config), documented under a "Potential Gotcha" heading. 1.4 ships...
Open Graph Description: Summary constants=None means "construct a fresh private Constants()" — a sentinel that means the opposite of what None conventionally means (the default here is the shared config), documented under...
X Description: Summary constants=None means "construct a fresh private Constants()" — a sentinel that means the opposite of what None conventionally means (the default here is the shared config), docume...
Opengraph URL: https://github.com/derek73/python-nameparser/issues/260
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Add Constants.copy(); deprecate constants=None","articleBody":"## Summary\n\n`constants=None` means \"construct a fresh private `Constants()`\" — a sentinel that means the opposite of what `None` conventionally means (the default here is the *shared* config), documented under a \"Potential Gotcha\" heading. 1.4 ships the explicit vocabulary and the deprecation warning; removal is #261 (2.0).\n\n```python\nHumanName(name) # shared CONSTANTS (unchanged)\nHumanName(name, constants=Constants()) # private, library defaults\nHumanName(name, constants=CONSTANTS.copy()) # private, snapshot of current shared config\n```\n\n## The trap the sentinel can't express\n\n\"Give me a private config\" is ambiguous between *fresh library defaults* and *a private snapshot of the current shared config*. `None` silently picks the first: customize `CONSTANTS.titles`, later pass `None` for \"my own config\", and the customizations are gone with no error. An explicit `Constants` argument forces the caller to answer the question; the missing piece is a nice spelling for the snapshot answer — `copy.deepcopy(CONSTANTS)` works (reliably since the 1.3.0 pickle/deepcopy fixes, which is what makes this cheap now), but nobody discovers `deepcopy` for config.\n\n## Checklist\n\n- [ ] Add `Constants.copy()` — deepcopy-based detached copy; `_on_change` rewiring is already handled by the deepcopy machinery landed in 1.3.0\n- [ ] `DeprecationWarning` when `constants=None` is passed explicitly, naming both replacements. Only *explicit* `None` warns — the signature default is `CONSTANTS`, so omitting the argument never hits the branch\n- [ ] Update the signature annotation in the same PR (`Constants | None` stays for 1.4, docstring marks `None` deprecated)\n- [ ] Docs in the same PR: the three-spelling vocabulary in customize.rst and a sentence on the defaults-vs-snapshot distinction\n","author":{"url":"https://github.com/derek73","@type":"Person","name":"derek73"},"datePublished":"2026-07-06T08:14:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/260/python-nameparser/issues/260"}
| 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:e90f08eb-4986-ed67-0ffc-cd4bf8c3c9fb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 90C0:1418:2BCEF9C:3F1483A:6A567B17 |
| html-safe-nonce | d03df2539e27291692f02c74caa07db7c22a493ff439e70d7b9c9656e081372d |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MEMwOjE0MTg6MkJDRUY5QzozRjE0ODNBOjZBNTY3QjE3IiwidmlzaXRvcl9pZCI6Ijc3OTgyOTg3MzYxOTY2MzYzOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | d166d7be0050a79e97c97803444c269b627cd285f5e42479d5e52ac3d91316fa |
| hovercard-subject-tag | issue:4817243358 |
| 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/260/issue_layout |
| twitter:image | https://opengraph.githubassets.com/d2b48ac08c6dd0eb1b624bfe6430652f75e7218684171bc90fce4e1cd9372edc/derek73/python-nameparser/issues/260 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/d2b48ac08c6dd0eb1b624bfe6430652f75e7218684171bc90fce4e1cd9372edc/derek73/python-nameparser/issues/260 |
| og:image:alt | Summary constants=None means "construct a fresh private Constants()" — a sentinel that means the opposite of what None conventionally means (the default here is the shared config), documented under... |
| 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 | 19b5ee9431dcfce15ab4b001d626e4e3a6ba1acb7be814813a52bbebd9a86ef5 |
| 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 | fc131753d059926755b1ab26f13a2c96a692f5d7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width