refactor: thin Python binder (delete the 120-file Python layer) - #3
Merged
Conversation
…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
force-pushed
the
refactor/thin-python-binder
branch
from
July 17, 2026 19:07
d5db002 to
5344026
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Completes the pure-Rust-core goal: words2num2/ is now a thin binder like num2words2/, with zero Python conversion/dispatch logic.
What
words2num(text, lang, to)(locale resolve + en-vs-reverse-table dispatch, previously done in Python). Bumped to 0.1.1 (published).__init__.py(pass-throughs to_rust),base.py(justWords2NumError),converters/auto.py(justQuantity+pluralize),__main__.py,_version.py.lang_*.py,formats.py,utils.py,compat.py,converters/sentence.py.Verify
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 removedCONVERTER_CLASSES).