Add basic number formatting#4461
Conversation
fanninpm
left a comment
There was a problem hiding this comment.
A few nitpicks regarding the usage of match expressions vs. if expressions. If you decide to apply these suggestions, please remember to run them through rustfmt.
|
@fanninpm Thanks for your advice! It's definitely better than before 👍👍 |
|
The newly added test seems fail in CPython 3.10 |
youknowone
left a comment
There was a problem hiding this comment.
test.test_format.FormatTest is now unexpected success because you correctly fixed it!
We now can remove @unittest.expectedFailure from the test.
|
@youknowone I don't know if this is right way, but I removed |
|
@notJoon it's the right way! You should also remove the Clippy seems to be complaining about the usage of the |
youknowone
left a comment
There was a problem hiding this comment.
Please resolve errors of Linux CI run
https://github.com/RustPython/RustPython/actions/runs/3980709695/jobs/6823974987
|
|
||
| fn get_separator_interval(&self) -> usize { | ||
| match self.format_type { | ||
| Some(FormatType::Number) => 9999, |
There was a problem hiding this comment.
Is this meaning something or just intended a big number? I think bigint can have more digits than 9999.
|
I thought this is done except for test decorators but seems still on working, right? |
| inter: i32, | ||
| sep: char, | ||
| disp_digit_cnt: i32, | ||
| padding: PaddingStyle, |
There was a problem hiding this comment.
I think we don't need this padding. It only allows whitespace or 0, but whitespace padding doesn't add seprator.
Description
Only basic functionalities have been implemented so that formatting can be applied and output even when a 'float' type number comes in.
However, not all functions are fully functional(i.e, decimal rounding or
infvalue handling.), so it seems that additional functions will need to be supplemented in the future.Example
Related Issue
#1656