Skip to content

Commit 26d261a

Browse files
derek73claude
andcommitted
docs: replace "Nothing breaks." with a check the reader can run
The claim was contradicted by the 2.0 removals list. Worse, it was unfalsifiable -- it gave a reader no way to find out whether their own code was affected. Replace it with the actual promise: if your suite runs clean on 1.4 under -W error::DeprecationWarning, it runs on 2.0. Verified against a live 1.4.0 -- 11 of the 15 removals do warn there. Name the four that do not, in a new "Before you upgrade" section: regexes assignment (including the CONSTANTS.regexes.bidi = False recipe 1.3.1 itself recommended), *_list assignment, positional Constants(), and subclass parsing-hook overrides. All four raise or warn on contact, so the reader meets them immediately. Call out separately the one removal that changes results in silence: HumanName.__eq__ is gone, so name == "John Smith" is now False. It warned on 1.4 and says nothing on 2.0, making it the only way to get a wrong answer without being told. Also drop "or never" from the migration framing -- the compatibility layer is removed in 3.0, as the next sentence says. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 24aa787 commit 26d261a

2 files changed

Lines changed: 42 additions & 10 deletions

File tree

README.rst

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,16 @@ Learn more
4444
Coming from 1.x
4545
----------------
4646

47-
Nothing breaks. 2.0 keeps ``HumanName`` and ``CONSTANTS`` working exactly
48-
as before — same imports, same attributes, same mutation API. See
47+
``HumanName`` and ``CONSTANTS`` keep working in 2.0 — same imports, same
48+
attributes, same mutation API. What 2.0 removes is the batch of
49+
deprecations 1.3 and 1.4 announced, so if your test suite runs clean on
50+
1.4 under ``python -W error::DeprecationWarning``, you are nearly done.
51+
Two things that check will not catch: four removals 1.4 never warned
52+
about, which all raise on contact, and one that changes results silently
53+
— ``name == "John Smith"`` is now ``False``.
4954
`Migrating from HumanName <https://nameparser.readthedocs.io/en/latest/migrate.html>`__
50-
for translating a v1 customization into the new API, whenever that's
51-
convenient for you.
55+
covers both, and translates a v1 customization into the new API whenever
56+
that's convenient for you.
5257

5358
See the `release log <https://nameparser.readthedocs.io/en/latest/release_log.html>`__
5459
for the full list of changes in the 2.0 series.

docs/migrate.rst

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
Migrating from HumanName
22
=========================
33

4-
Nothing breaks. 2.0 keeps ``HumanName`` and ``CONSTANTS`` working
5-
exactly as before — same imports, same attributes, same mutation API
6-
(``name.C.titles.add(...)``, ``name.first = "..."``, and so on).
7-
Upgrading to 2.0 and migrating your code to the new
8-
:class:`~nameparser.Parser`/:class:`~nameparser.Lexicon`/
4+
``HumanName`` and ``CONSTANTS`` keep working in 2.0 — same imports,
5+
same attributes, same mutation API (``name.C.titles.add(...)``,
6+
``name.first = "..."``, and so on). Upgrading to 2.0 and migrating your
7+
code to the new :class:`~nameparser.Parser`/:class:`~nameparser.Lexicon`/
98
:class:`~nameparser.Policy` API are two separate decisions — you can do
10-
the former today and the latter whenever it's convenient, or never. The
9+
the former today and the latter whenever it's convenient. The
1110
compatibility layer (``HumanName`` and ``nameparser.config``) is
1211
removed in 3.0; that release is not scheduled.
1312

@@ -19,6 +18,34 @@ This page exists for the other direction: translating a v1
1918
customization or a v1-shaped comparison into the 2.0 API, one row per
2019
old name.
2120

21+
Before you upgrade
22+
------------------
23+
24+
What 2.0 removes is the batch of deprecations 1.3 and 1.4 announced. If
25+
your test suite runs clean on 1.4 under ``python -W
26+
error::DeprecationWarning``, it will run on 2.0 — with four exceptions
27+
that 1.4 never warned about, each of which fails loudly the first time
28+
you hit it:
29+
30+
* ``CONSTANTS.regexes.<name> = ...`` raises ``TypeError``. This includes
31+
``CONSTANTS.regexes.bidi = False``, the opt-out 1.3.1 recommended for
32+
keeping bidirectional marks; the 2.0 spellings are
33+
``Policy(strip_bidi=False)`` and ``Policy(strip_emoji=False)``
34+
* assigning a ``*_list`` attribute (``name.first_list = [...]``) raises
35+
``AttributeError`` — the lists are read-only snapshots in 2.0
36+
* positional ``Constants(...)`` construction raises ``TypeError``; the
37+
constructor is keyword-only
38+
* a subclass overriding a v1 parsing hook (``pre_process``,
39+
``parse_pieces``, ``is_title``, and the rest) gets a
40+
``DeprecationWarning`` at construction naming the hooks it overrode,
41+
because 2.0 delegates parsing to the core parser and never calls them
42+
43+
One removal changes results without saying anything. ``HumanName`` no
44+
longer defines ``__eq__``, so ``name == "John Smith"`` is now ``False``
45+
where 1.x returned ``True``. That one *did* warn on 1.4, but nothing
46+
will tell you on 2.0. If you compare names anywhere, grep for ``==``
47+
before upgrading and move to ``matches()`` — see `Comparison`_.
48+
2249
Attribute map
2350
-------------
2451

0 commit comments

Comments
 (0)