-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Numeric formatting #467
Comments
Hi, |
I realize this would make the rules less consistent, but I think this deserves a special case. In most fonts,
I also think
I think the second one is actually really helpful because it's easy to miss an extra dot at the end of a line. I don't have as strong of an opinion on |
OK, I'm going to go with these two changes (capitalize |
I recently landed a diff adding normalization of numeric literals (#454, #464), but I want to make sure we all agree on the behavior before this goes into a release. It would be bad for user trust in Black if we change formatting in a release, then change our mind again in another release, so I'd rather discuss these now before they're locked into a release.
Here are the formatting rules included in my diff:
123456789
->123_456_789
0.12345678
->0.12_345_678
0.123_456_78
instead? Or perhaps we don't need underscores at all in the fractional part of floats; my code adds it to any part of a numeric literal that consists of multiple digits.1E10
->1e10
, and similarly2J
->2j
and (Python 2)2L
->2l
1e+10
->1e10
0XABCD
->0xabcd
(so generally, all letters are lowercased).1
->0.1
and1.
->1.0
0xabcdefgh
stays unchanged, instead of changing to0x_abcd_efgh
or similar. Similarly, no underscores in octal or binary literals. PEP 515 (https://www.python.org/dev/peps/pep-0515/#id26) suggests splitting hex literals by words and binary literals by nybbles in examples. The current code also doesn't remove any underscores in hex/oct/bin literals.Let me know if you disagree with any of these. If nobody feels strongly, we can just stick with the current behavior.
The text was updated successfully, but these errors were encountered: