Fix complex zero-padding error priority - #8453
Merged
youknowone merged 2 commits intoAug 4, 2026
Merged
Conversation
Contributor
|
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 |
shAn-kor
marked this pull request as ready for review
August 4, 2026 10:08
1 task
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.
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