Python ignores whitespace in format strings by youknowone · Pull Request #6447 · RustPython/RustPython
Walkthrough
This PR adds three new spell-check dictionary entries (DICTFLAG, keeped, stginfo) and modifies the struct format string parser in the buffer module to skip whitespace after repeat counts and handle missing format specifiers based on whether a non-default repeat was specified.
Changes
| Cohort / File(s) | Summary |
|---|---|
Spell-check dictionary .cspell.dict/cpython.txt |
Added three new entries: DICTFLAG, keeped, and stginfo to the allowed words list. |
Struct format parsing crates/vm/src/buffer.rs |
Modified format string parser to skip whitespace (space, tab, newline, carriage return) after repeat counts. Adjusted logic to read the format character after whitespace, with conditional error handling: returns error if no format character follows a non-default repeat count (repeat != 1), otherwise stops parsing gracefully. |
Estimated code review effort
🎯 2 (Simple) | ⏱️ ~15 minutes
- buffer.rs logic: Requires verification that whitespace-skipping doesn't inadvertently consume format specifiers and that error conditions (missing specifier vs. default repeat) are correctly handled.
- Dictionary entries: Confirm these are intentional keyword additions without typos.
Poem
🐰 A hopping through format strings with glee,
Whitespace begone! We skip merrily,
Three words join the spell-check spree,
Parsing cleaner, errors run free! ✨
Pre-merge checks and finishing touches
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
✅ Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | ✅ Passed | Check skipped - CodeRabbit’s high-level summary is enabled. |
| Title check | ✅ Passed | The title accurately describes the main change: adding whitespace handling in format string parsing, which aligns with the buffer.rs modifications. |
✨ Finishing touches
- 📝 Generate docstrings
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Post copyable unit tests in a comment
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.