Skip to content

Commit 810ff89

Browse files
derek73claude
andcommitted
docs: fix broken initials doctests and add release_log entry for initials fix
The usage.rst initials doctests had unterminated strings, wrong expected output (Python list repr, leaked global initials_format), and a missing blank line after a doctest directive. Fix them to pass under the doctest builder and reset CONSTANTS.initials_format so they don't leak state. Add an Unreleased release_log entry for the initials() None fix, the python -m nameparser CLI, and the pytest test reorg. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent b359304 commit 810ff89

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

docs/release_log.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Release Log
22
===========
3+
* Unreleased
4+
- Fix ``initials()`` interpolating the literal ``None`` for empty name parts when ``empty_attribute_default = None`` (e.g. ``"J. None D."``); empty parts now render as an empty string and a fully-empty result returns ``empty_attribute_default``
5+
- Add ``python -m nameparser "Name String"`` command-line helper that prints a parsed name
6+
- Reorganize the test suite from a single ``tests.py`` into a ``tests/`` pytest package
37
* 1.2.0 - June 11, 2026
48
- Drop Python 2 and Python < 3.10 support; Python 3.10–3.14 now required
59
- Add type hints and type declarations (PEP 561 ``py.typed`` marker)

docs/usage.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ Three attributes exist for the format, `first`, `middle` and `last`.
191191
>>> CONSTANTS.initials_format = "{first} {middle}"
192192
>>> HumanName("Doe, John A. Kenneth, Jr.").initials()
193193
'J. A. K.'
194-
>>> HumanName("Doe, John A. Kenneth, Jr.", initials_format="{last}, {first}).initials()
194+
>>> HumanName("Doe, John A. Kenneth, Jr.", initials_format="{last}, {first}").initials()
195195
'D., J.'
196+
>>> CONSTANTS.initials_format = "{first} {middle} {last}"
196197

197198

198199
Furthermore, the delimiter for the string output can be set through:
@@ -201,16 +202,15 @@ Furthermore, the delimiter for the string output can be set through:
201202
.. doctest:: initials delimiter
202203

203204
>>> HumanName("Doe, John A. Kenneth, Jr.", initials_delimiter=";").initials()
204-
"J; A; K;"
205-
>>> from nameparser.config import CONSTANTS
206-
>>> CONSTANTS.initials_delimiter = "."
207-
>>> HumanName("Doe, John A. Kenneth, Jr.", initials_format="{first}{middle}{last}).initials()
208-
"J.A.K.D."
205+
'J; A; K; D;'
206+
>>> HumanName("Doe, John A. Kenneth, Jr.", initials_format="{first}{middle}{last}", initials_delimiter=".").initials()
207+
'J.A. K.D.'
209208

210209
To get a list representation of the initials, use :py:meth:`~nameparser.HumanName.initials_list`.
211210
This function is unaffected by :py:attr:`~nameparser.config.Constants.initials_format`
212211

213212
.. doctest:: list format
213+
214214
>>> HumanName("Doe, John A. Kenneth, Jr.", initials_delimiter=";").initials_list()
215-
["J", "A", "K", "D"]
215+
['J', 'A', 'K', 'D']
216216

0 commit comments

Comments
 (0)