-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
needs-decisionAwaiting a decision from a maintainerAwaiting a decision from a maintainerneeds-designNeeds further design before implementationNeeds further design before implementationruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
I would like to implement a rule for PEP 515. This allows using underscores as visual separators in numerics. Large numbers are hard to read and using underscore as thousands, millions, etc. separators increases readability a lot.
E.g this would turn this:
my_large_int = 313391313513489341into:
my_large_int = 313_391_313_513_489_341A few things I have in mind:
- underscore would be added as thousands, millions, billions, etc. separator, so every 3 digits
- for float, it probably makes sense to add it as thousandths, millionths, etc.
- for integers <= 99999 (so 5 or less digits), no need to add a thousands separator, those are readable enough without it
- for hexadecimal notation, add an underscore every 4 digits, if the length is > 4 (eg.
0x15_DEAD_BEEF). Would it make sense to left-pad with 0 to have a length that is a multiple of 4 (so0x0015_DEAD_BEEF) ? - for binary notation, add an underscore every 8 digits (eg.
0b1100110_01101111_01101111). Would it make sense to left pad with 0 up to a multiple of 8 (so0b01100110_01101111_01101111) ?
I did not find any prior art so if such a rule exists somewhere else, feel free to point me to it as well.
This would be my first Ruff rule and one of my first experiments with Rust, so I'm looking for feedback about the rule itself before I start coding it. If you feel this is not implementable for any reason, just let me know as well :)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
needs-decisionAwaiting a decision from a maintainerAwaiting a decision from a maintainerneeds-designNeeds further design before implementationNeeds further design before implementationruleImplementing or modifying a lint ruleImplementing or modifying a lint rule