Skip to content

Commit 3687d0d

Browse files
committed
fix: update boolean function to handle both string and boolean inputs correctly
Fix #442 Signed-off-by: Frost Ming <[email protected]>
1 parent 6042e0c commit 3687d0d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- Custom encoders can now receive `_parent` and `_sort_keys` parameters to enable proper encoding of nested structures. ([#429](https://github.com/python-poetry/tomlkit/issues/429))
88

9+
## Fixed
10+
11+
- Fixed `tomlkit.boolean()` API to correctly handle boolean inputs. ([#442](https://github.com/python-poetry/tomlkit/issues/442))
12+
913
## [0.13.3] - 2025-06-05
1014

1115
### Added

tomlkit/api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,9 @@ def float_(raw: str | float) -> Float:
117117
return item(float(raw))
118118

119119

120-
def boolean(raw: str) -> Bool:
120+
def boolean(raw: str | bool) -> Bool:
121121
"""Turn `true` or `false` into a boolean item."""
122-
return item(raw == "true")
122+
return item(raw == "true" if isinstance(raw, str) else raw)
123123

124124

125125
def string(

0 commit comments

Comments
 (0)