Fix complex zero-padding error priority - #8453
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe change extracts shared validation for complex number padding and alignment. Standard and locale-aware formatting now use the same checks. New tests cover invalid zero-padding and after-sign alignment specifications. ChangesComplex format validation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
What changed
For complex values,
0padding and=alignment are both invalid. When a format spec contains both, CPython raises the zero-padding error first. RustPython returned the alignment error in the regular formatting path, and the locale-awarenpath applied the checks separately.The validation now lives in one helper used by both paths. Specs such as
=08.1fand=08nreport the zero-padding error;=8.1fand=8nstill report the alignment error.The regression tests cover both paths.
Tests
cargo test -p rustpython-common format_complex_cargo run --release -- -m test test_complexcargo clippy -p rustpython-common --all-targets -- -D warningscargo fmt --all -- --checkAI assistance
Codex (GPT-5) assisted with comparing CPython and RustPython behavior, drafting the implementation and regression tests, and writing this PR description.
Summary by CodeRabbit