Parse Error in SonarPython when using numeric literal separators


(Adam Parkin) #1

Steps to Reproduce:

Put a numeric constant with separators (new in Python 3.6):

MAX_AMOUNT = 9_999_999_999.99

With v1.10 of the SonarPython plugin, this produces a parse error:

--> MAX_AMOUNT = 9_999_999_999.99

It’s perhaps worth noting that the popular Python code formatter Black will automatically insert these on large numeric literals.

(Adam Parkin) #2

The PEP which outlines the support of underscores in numeric literals:

(Alban Auzeill) #3

Hi Adam,
Yes, I can reproduce. Of course we should improve this, ticket created SONARPY-293.
Thanks for your feedback and your help with the PEP reference :+1: