You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: honor initials_separator kwarg in __process_initial__; fix string_format='' in __str__
- `__process_initial__` was reading `self.C.initials_separator` (Constants)
instead of `self.initials_separator` (per-instance), so the constructor kwarg
was silently ignored for multi-word name parts
- `__str__` used `if self.string_format:` (truthiness) so `string_format=""`
fell through to the default format despite the assignment fix in the PR
- Add regression tests for both kwarg paths through the affected code
- Fix `test_initials_separator_multiword_name_part` to set instance attr instead
of Constants attr, so it tests the now-correct code path
- Correct `Constants.initials_separator` docstring example (requires
initials_format="{first}{middle}{last}" to produce "J.A.D.")
- Clarify usage.rst: initials_separator only removes intra-group spaces;
inter-group spacing is still governed by initials_format
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: docs/usage.rst
+3-2Lines changed: 3 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -206,12 +206,13 @@ Furthermore, the delimiter for the string output can be set through:
206
206
207
207
The separator between consecutive initials *within* a name group (e.g. two middle
208
208
names) is controlled by :py:attr:`~nameparser.config.Constants.initials_separator`,
209
-
which defaults to ``" "``. Setting it to ``""`` removes that space.
209
+
which defaults to ``" "``. Setting it to ``""`` removes that space within a group;
210
+
spacing *between* groups is still governed by ``initials_format``.
210
211
211
212
``initials_delimiter``, ``initials_separator``, and ``initials_format`` work together:
212
213
213
214
- ``initials_delimiter`` — appended *after* each individual initial (default ``"."``)
214
-
- ``initials_separator`` — placed *between* consecutive initials in the same group (default ``" "``)
215
+
- ``initials_separator`` — placed *after* the delimiter between consecutive initials in the same group (default ``" "``), so with ``delimiter="."`` and ``separator=" "`` you get ``A. K.``
215
216
- ``initials_format`` — controls how the first, middle, and last groups are arranged
216
217
217
218
For example, to produce compact period-separated initials with no spaces:
0 commit comments