Skip to content

Remove nameparser.config.regexes, which the parser has not read since 2.0 (#1008) - #1010

Merged
derek73 merged 3 commits into
masterfrom
feat/remove-config-regexes
Nov 3, 2026
Merged

derek73 merged 3 commits into
masterfrom
feat/remove-config-regexes

Conversation

@derek73

@derek73 derek73 commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Closes #1008.

Note

3.0 is not released before 2.8.1, which warns of it. 2.8.1, built on the 2.x branch, carries the DeprecationWarning that announces this removal. It is raised where code reads a constant of nameparser.config.regexes (from nameparser.config.regexes import REGEXES included); importing the module alone stays quiet. Every 3.0 removal warns in a released version first (decisions/3-0-reevaluations' standing discipline). This PR may merge to master before 2.8.1 ships, so the 3.0 migration guide that 2.8.1's warnings link to is live on readthedocs.

What changes

  • nameparser/config/regexes.py is deleted. from nameparser.config.regexes import REGEXES raises ImportError. Parsing is unchanged: snapshot.py reports no moves.

  • tests/v2/test_regex_sync.py pins each hand copy to the pipeline's pattern, not to the config table. _SOURCES now maps each copy to the (module, attribute) it must equal:

    • _render._ROMAN → _vocab._ROMAN.
    • _render._INITIAL → _vocab._INITIAL. This is now a straight copy; before, it was compared to config's initial with one ? spliced back in.
    • The imports _pieces/_assemble._PERIOD_ABBREV, _pieces/_assign._ROMAN and _classify._INITIAL → their _vocab original.

    The test that the two initial copies agree, the dotted-initial test, the comma-set test and the completeness checks all stay.

  • Docs:

    • migrate.rst: a removals row (copy the pattern you reused; bidi and emoji are Policy(strip_bidi=...)/Policy(strip_emoji=...)). "Finding the sites" now says upgrade to 2.8.1 and that 2.8.1 warns where a constant of regexes is read. It lists a bare import of the module among the code that passes the warnings check and still fails on 3.0, and adds config.regexes to the names to search for.
    • customize.rst: the freeze paragraph names CAPITALIZATION_EXCEPTIONS alone.
    • modules.rst: the automodule entry and its "compiled patterns in regexes" clause are gone.
    • release log: a Breaking Changes bullet saying 2.8.1 warns where a constant of the module is read.
    • mechanisms.md Field notes: before deleting a pin, mutate each pattern it pins (Remove nameparser.config.regexes in 3.0? The parser has not read REGEXES since 2.0 #1008's three unguarded patterns).
  • decisions/3-0-reevaluations: a 2026-11-02 Remove nameparser.config.regexes in 3.0? The parser has not read REGEXES since 2.0 #1008 entry superseding the 2026-10-28 Remove the 1.x vocabulary names (PREFIXES, FIRST_NAME_TITLES, …) and their bridge #357 entry's listing of regexes among the nameparser.config modules that stay. The Standing line and the superseded entry's parenthetical are updated to match.

  • Smaller changes:

    • test_contracts.py drops regexes.REGEXES from the freeze test's exempt mappings.
    • Provenance comments in _vocab.py, _render.py, _tokenize.py and _pieces.py no longer point at the deleted file.
    • Root and nameparser/ AGENTS.md no longer point at it either, and the mypy gotcha gets a current example.

Patterns whose only other copy was the config table

  • _render._SPACES, _SPACE_BEFORE_COMMA, _MAC and _WORD, _vocab._PERIOD_NOT_AT_END and _tokenize._BIDI have nothing left to sync with. They are declared in _SOURCES with None.
  • _vocab._MARKS and _tokenize._EMOJI_RANGES are not compiled patterns, so they were never in the roster, and their dedicated tests are removed.
  • The four _vocab patronymic patterns keep their pin through test_locales.py::test_a_packs_marker_regexes_are_the_rules_its_patch_turns_on, which holds the RU and TR_AZ packs' copies to them.

Three of these patterns had no other tripwire. Dropping U+1AB0-1AFF from _MARKS, or narrowing _SPACES or _SPACE_BEFORE_COMMA to a literal space, passed the whole suite. Behavior tests now catch each one:

  • test_a_mark_from_each_combining_block_stays_in_its_word in test_parser.py: a mark from each of the five combining blocks keeps Dr. inz◌. Janez Novak's abbreviation a title.
  • test_collapse_reads_any_whitespace_as_a_space in test_render.py: a tab, no-break space or ideographic space in a spec collapses, before a comma too.

Verification

  • Every two-sided pin was run against a drifted copy, once with the pattern changed and once with the flags changed, and fails both times. That covers 7 roster entries plus test_initial_copies_agree.
  • The three new behavior tests were each run against their mutation and fail: 1, 3 and 3 cases.
  • uv run pytest -q (34,784 passed), uv run pytest -q -n0 -m serial (42 passed), uv run mypy, uv run ruff check, sphinx-build -b doctest docs (0 failures) and -W -b html, python -m doctest README.rst, and tools/differential/snapshot.py ("matches the snapshot").
  • One serial run failed three scaling-ratio rows under a machine load average of 16 to 25. They passed on rerun, and the only nameparser/ change since the last full pass is a comment.

🤖 Generated with Claude Code

… 2.0 (#1008)

The REGEXES table configured only the v1 parser; since 2.0 it held a
third copy of the patterns the pipeline and render hand-copy, and
tests/v2/test_regex_sync.py pinned both copies to it as the source.
That test now pins each hand copy to the pipeline's own pattern
(_render._ROMAN to _vocab._ROMAN, _render._INITIAL to _vocab._INITIAL),
and a pattern whose only other copy was the config table is declared
with no source.

Drops REGEXES from the freeze test's exempt mappings and the module
from docs/modules.rst; adds a migrate.rst removals row, the customize
freeze paragraph naming CAPITALIZATION_EXCEPTIONS alone, a release-log
Breaking Changes bullet, and a decisions/3-0-reevaluations entry
superseding the #357 entry's listing of regexes among the modules that
stay. Provenance comments no longer point at the deleted file.

Lands after 2.8.1, which warns on the import.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derek73 derek73 added this to the 3.0 milestone Nov 3, 2026
@derek73 derek73 added the breaking-change Backwards-incompatible API change label Nov 3, 2026
@derek73 derek73 self-assigned this Nov 3, 2026
derek73 and others added 2 commits November 2, 2026 19:49
The config pins were the only tripwire for _vocab._MARKS's
U+1AB0-1AFF block and for _render._SPACES and _SPACE_BEFORE_COMMA's
\s: narrowing any of them failed nothing once config's copies left.
Behavior tests now catch each (a mark from every combining block
keeps its abbreviation a title; any whitespace in a spec collapses,
before a comma too), each run against its mutation.

migrate.rst's "Finding the sites" says upgrade to 2.8.1, names the
one import that warns and adds config.regexes to the search list;
modules.rst drops "the compiled patterns in regexes". The decisions
entry corrects which names left the roster and which lost their
tests, and states the timing as 3.0 not releasing before 2.8.1.
AGENTS.md's mypy gotcha gets a current example; _pieces' and
test_contracts' comments are reworded and reflowed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…1008)

2.8.1 warns through the module's __getattr__, so `from
nameparser.config.regexes import REGEXES` warns and a bare import of
the module stays quiet. migrate.rst's removals intro and "Finding the
sites" now say so, the bare import joining the list of code that
passes the warnings check and still fails on 3.0, and the release
bullet says "where a constant of it is read". Reflows modules.rst's
paragraph, and adds a mechanisms.md field note: before deleting a
pin, mutate each pattern it pins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@derek73
derek73 merged commit fbcd08e into master Nov 3, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change Backwards-incompatible API change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove nameparser.config.regexes in 3.0? The parser has not read REGEXES since 2.0

1 participant