flake8-simplify
flake8-simplify copied to clipboard
[New Rule] Underscores in Numeric Literals
Explanation
Using underscore on large number make for better comprehension.
This feature was introduced with python 3.6 and PEP515 describe it.
Example
# Bad
amount = 10000000.0
addr = 0xCAFEF00D
flags = 0b0011111101001110
flags = int('0b11110000', 2)
# Good
amount = 10_000_000.0
addr = 0xCAFE_F00D
flags = 0b_0011_1111_0100_1110
flags = int('0b_1111_0000', 2)
Related: https://github.com/frequenz-floss/flake8-numbers/pull/4/files