Skip to content

Commit c2c9e73

Browse files
Handle conversions.bool (#137)
Again, pulled out of #135.
1 parent 9a7791d commit c2c9e73

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

src/celpy/celtypes.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,12 @@ def __new__(cls: Type["BoolType"], source: Any) -> "BoolType":
398398
return source
399399
elif isinstance(source, MessageType):
400400
return super().__new__(cls, cast(int, source.get(StringType("value"))))
401+
elif isinstance(source, (str, StringType)):
402+
if source in ("False", "f", "FALSE", "false"):
403+
return super().__new__(cls, 0)
404+
elif source in ("True", "t", "TRUE", "true"):
405+
return super().__new__(cls, 1)
406+
return super().__new__(cls, source)
401407
else:
402408
return super().__new__(cls, source)
403409

tools/wip.toml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -223,16 +223,6 @@ not_ne_int_uint = "@wip"
223223
not_ne_uint_double = "@wip"
224224
not_ne_uint_double_nan = "@wip"
225225

226-
[conversions.bool]
227-
string_f = "@wip"
228-
string_false_lowercase = "@wip"
229-
string_false_pascalcase = "@wip"
230-
string_false_uppercase = "@wip"
231-
string_t = "@wip"
232-
string_true_lowercase = "@wip"
233-
string_true_pascalcase = "@wip"
234-
string_true_uppercase = "@wip"
235-
236226
[conversions.identity]
237227
timestamp = "@wip"
238228

0 commit comments

Comments
 (0)