tomlkit icon indicating copy to clipboard operation
tomlkit copied to clipboard

Sign change when doing math gives invalid number

Open michi12321 opened this issue 3 months ago • 0 comments

Bug:

>>> d = tomlkit.parse('x=-3.1415')
>>> d['x'] *= -1
>>> print(tomlkit.dumps(d))

returns:

a=+3.1415

>>> d['x'] *= -1
>>> print(tomlkit.dumps(d))

returns:

a=--3.1415

Subsequent parsing raises tomlkit.exceptions.InvalidNumberError.

Of course there is an easy workaround using type conversion: d['x'] = float(d['x'])*-1.

michi12321 avatar Apr 29 '24 20:04 michi12321