Skip to content

Commit bf01a25

Browse files
authored
fix: don't add sign if the float is negative (#345)
Fix #341 Signed-off-by: Frost Ming <[email protected]>
1 parent 059fab2 commit bf01a25

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## [unreleased]
4+
5+
### Fixed
6+
7+
- Remove the extra minus sign added to the float value after calculation. ([#341](https://github.com/python-poetry/tomlkit/issues/341))
8+
39
## [0.12.4] - 2024-02-27
410

511
### Fixed

tomlkit/items.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -714,9 +714,8 @@ def as_string(self) -> str:
714714
def _new(self, result):
715715
raw = str(result)
716716

717-
if self._sign:
718-
sign = "+" if result >= 0 else "-"
719-
raw = sign + raw
717+
if self._sign and result >= 0:
718+
raw = f"+{raw}"
720719

721720
return Float(result, self._trivia, raw)
722721

0 commit comments

Comments
 (0)