Repository navigation
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported, and the change preserves compatibility while covering the deprecated wrappers and internal helper usage in the reviewed updates.
No open issues 🎉
What changed in this PR
This PR deprecates the public JavaScript lexer helpers while preserving backward compatibility through warning-emitting wrappers. Internal extraction and lexer tests now use underscore-prefixed implementations.
Changes:
- Renames
tokenize,get_rules, andindicates_divisionto internal underscore-prefixed functions. - Adds deprecated compatibility wrappers that emit
DeprecationWarning. - Updates JavaScript extraction and lexer tests to use internal helpers and verify deprecation behavior.
| File | Description |
|---|---|
| tests/messages/test_jslexer.py | Updates lexer tests to use private helpers and verifies that deprecated wrappers emit warnings. |
| babel/messages/jslexer.py | Adds underscore-prefixed lexer implementations and backward-compatible deprecation wrappers. |
| babel/messages/extract.py | Updates JavaScript message extraction to use the private tokenizer. |
Review effort: Lite
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1459 +/- ##
==========================================
- Coverage 93.67% 92.93% -0.75%
==========================================
Files 27 27
Lines 4983 4994 +11
==========================================
- Hits 4668 4641 -27
- Misses 315 353 +38
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
dcd9458 to
0a032f6
Compare
The lexer is an implementation detail of the JavaScript message extractor and has never been documented. This renames methods there to underscore-prefixed names, and leaves wrappers under the old names that emit a DeprecationWarning.
0a032f6 to
0ebcb83
Compare
tomasr8
left a comment
There was a problem hiding this comment.
Looks good :)
I have a grand plan to replace it outright with something better
Looking forward to it 👍
| def _warn_deprecated(name: str) -> None: | ||
| warnings.warn( | ||
| f"`babel.messages.jslexer.{name}` is an implementation detail of the JavaScript " | ||
| f"message extractor; it is deprecated and will be removed in a future version of Babel.", |
There was a problem hiding this comment.
Super nitpicky, but this does not strictly need to be an f-string, but fine to leave as is if you prefer to keep the alignment:
| f"message extractor; it is deprecated and will be removed in a future version of Babel.", | |
| "message extractor; it is deprecated and will be removed in a future version of Babel.", |
Merging this PR will not alter performance1 warning
Comparing Footnotes |
The lexer is an implementation detail of the JavaScript message extractor and has never been documented.
This renames functions there to underscore-prefixed names with wrappers under the old names that emit a DeprecationWarning.
Given how many bugs and corner cases there seem to be in the JS extractor, I have a grand plan to replace it outright with something better, probably in Babel 2.20. However, this has still been a public if undocumented module.