Skip to content

refactor: thin Python binder (delete the 120-file Python layer) - #3

Merged
jqueguiner merged 1 commit into
mainfrom
refactor/thin-python-binder
Jul 17, 2026
Merged

refactor: thin Python binder (delete the 120-file Python layer)#3
jqueguiner merged 1 commit into
mainfrom
refactor/thin-python-binder

Conversation

@jqueguiner

Copy link
Copy Markdown
Owner

Completes the pure-Rust-core goal: words2num2/ is now a thin binder like num2words2/, with zero Python conversion/dispatch logic.

What

  • words2num2-core gains a top-level words2num(text, lang, to) (locale resolve + en-vs-reverse-table dispatch, previously done in Python). Bumped to 0.1.1 (published).
  • words2num2/ reduced to 6 thin files: __init__.py (pass-throughs to _rust), base.py (just Words2NumError), converters/auto.py (just Quantity + pluralize), __main__.py, _version.py.
  • Deleted 122 files: all 118 lang_*.py, formats.py, utils.py, compat.py, converters/sentence.py.

Verify

  • cargo test green, clippy clean, cargo publish --dry-run (0.1.1) passes.
  • pytest tests/: 114 passed, 1 skipped (was 116/1 — the −2 are the deleted-layer dispatch tests referencing the removed CONVERTER_CLASSES).

…layer

words2num2/ is now a thin binder over the Rust core, matching num2words2/. All
locale resolution, en-grammar parsing, reverse-table lookup and mode dispatch
live in words2num2-core; the Python package only binds _rust and surfaces the
exception/result types.

- words2num2-core: add top-level `words2num(text, lang, to)` (resolve_lang +
  CONVERTER_TYPES check + en-vs-reverse-table dispatch) so no dispatch remains
  in Python. Bump to 0.1.1.
- binder: expose `#[pyfunction] words2num`.
- words2num2/__init__.py: thin pass-throughs to _rust (words2num,
  words2num_sentence, auto_parse, auto_parse_sentence, parse_number_string,
  normalize, supported_langs) + Words2NumError / Quantity surface.
- Delete 122 files: all 118 lang_*.py, formats.py, utils.py, compat.py,
  converters/sentence.py. base.py keeps only Words2NumError; converters/auto.py
  keeps only Quantity + pluralize (the names _rust imports).
- tests: drop the 2 dispatch tests referencing the removed CONVERTER_CLASSES.

Verified: cargo test green, clippy clean, words2num2-core 0.1.1 published;
pytest 114 passed / 1 skipped (was 116/1 — the 2 removed are the deleted-layer
dispatch tests).
@jqueguiner
jqueguiner force-pushed the refactor/thin-python-binder branch from d5db002 to 5344026 Compare July 17, 2026 19:07
@jqueguiner
jqueguiner merged commit 8ffb512 into main Jul 17, 2026
35 checks passed
@jqueguiner
jqueguiner deleted the refactor/thin-python-binder branch July 17, 2026 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant