-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add basic number formatting #4461
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
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.
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
|
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.
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 |
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.
Please resolve errors of Linux CI run
https://github.com/RustPython/RustPython/actions/runs/3980709695/jobs/6823974987
@@ -384,14 +404,20 @@ impl FormatSpec { | |||
|
|||
fn get_separator_interval(&self) -> usize { | |||
match self.format_type { | |||
Some(FormatType::Number) => 9999, |
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.
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? |
@@ -312,13 +334,15 @@ impl FormatSpec { | |||
inter: i32, | |||
sep: char, | |||
disp_digit_cnt: i32, | |||
padding: PaddingStyle, |
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.
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
inf
value handling.), so it seems that additional functions will need to be supplemented in the future.Example
Related Issue
#1656