Skip to content

Commit

Permalink
fix: don't add sign if the float is negative (#345)
Browse files Browse the repository at this point in the history
Fix #341

Signed-off-by: Frost Ming <me@frostming.com>
  • Loading branch information
frostming committed May 7, 2024
1 parent 059fab2 commit bf01a25
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change Log

## [unreleased]

### Fixed

- Remove the extra minus sign added to the float value after calculation. ([#341](https://github.com/python-poetry/tomlkit/issues/341))

## [0.12.4] - 2024-02-27

### Fixed
Expand Down
5 changes: 2 additions & 3 deletions tomlkit/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -714,9 +714,8 @@ def as_string(self) -> str:
def _new(self, result):
raw = str(result)

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

return Float(result, self._trivia, raw)

Expand Down

0 comments on commit bf01a25

Please sign in to comment.