-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Panic occurs when formatting with separator and some format specifier #6213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughExtended magnitude-separator logic to return a separator interval of 3 for additional numeric format types (Decimal, FixedPoint, GeneralFormat, Exponent, Percentage) and added tests exercising thousands-separator format specifiers for floats and integers. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Caller as Formatting code
participant GetSep as get_separator_interval
note over GetSep #D3E4CD: Updated matching logic
Caller->>GetSep: request separator interval for FormatKind
alt FormatKind in {Binary, Octal, Hex}
GetSep-->>Caller: returns 3
else FormatKind in {Decimal, FixedPoint, GeneralFormat, Exponent, Percentage}
GetSep-->>Caller: returns 3
else FormatKind == None
GetSep-->>Caller: returns 3
else
GetSep-->>Caller: panic (non-number format)
end
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
common/src/format.rs(1 hunks)extra_tests/snippets/builtin_format.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
extra_tests/**/*.py
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
extra_tests/**/*.py: Follow PEP 8 style for custom Python code
Use ruff to lint custom Python code
Files:
extra_tests/snippets/builtin_format.py
**/*.rs
📄 CodeRabbit inference engine (.github/copilot-instructions.md)
**/*.rs: Format Rust code with the default rustfmt style (runcargo fmt)
Run clippy and fix any warnings or lints introduced by your changes
Follow Rust best practices for error handling and memory management
Files:
common/src/format.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
- GitHub Check: Check the WASM package and demo
- GitHub Check: Run snippets and cpython tests on wasm-wasi
- GitHub Check: Run snippets and cpython tests (macos-latest)
- GitHub Check: Run tests under miri
- GitHub Check: Run snippets and cpython tests (windows-latest)
- GitHub Check: Run snippets and cpython tests (ubuntu-latest)
- GitHub Check: Run rust tests (windows-latest)
- GitHub Check: Run rust tests (ubuntu-latest)
- GitHub Check: Run rust tests (macos-latest)
- GitHub Check: Check Rust code with rustfmt and clippy
- GitHub Check: Ensure compilation on various targets
🔇 Additional comments (1)
extra_tests/snippets/builtin_format.py (1)
191-195: LGTM! Comprehensive test coverage for new separator support.The new test cases properly validate separator functionality with GeneralFormat (g/G), Exponent (e/E), and Percentage (%) format types. The expected outputs are correct:
- For general format with 123456, the separator applies to the integer representation
- For exponent format, no separator appears because the mantissa "1" is too short
- For percentage, the separator correctly applies to the scaled value (12,345,600)
Good coverage of both uppercase and lowercase format specifiers.
|
@yt2b this looks very good, I think that it's worth adding those tests upstream (to cpython). I find it odd that they don't have a test for it |
youknowone
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 Thank you!
Summary
#6212
I've fixed get_separator_interval.
And I've added extra tests.
Summary by CodeRabbit
New Features
Tests