Skip to content

Commit 31b8029

Browse files
committed
Fix default encoding using json.dumps and loads
1 parent 17c1a10 commit 31b8029

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

radicli/util.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import inspect
99
import argparse
1010
import re
11+
import json
1112

1213
# We need this Iterable type, which is the type origin of types.Iterable
1314
try:
@@ -218,9 +219,9 @@ def to_static_json(self) -> StaticArg:
218219
"option": self.arg.option,
219220
"short": self.arg.short,
220221
"orig_help": self.arg.help,
221-
"default": str(self.default)
222-
if self.default not in (False, None)
223-
else self.default,
222+
"default": DEFAULT_PLACEHOLDER
223+
if self.default == DEFAULT_PLACEHOLDER
224+
else json.dumps(self.default),
224225
"help": self.help,
225226
"action": str(self.action) if self.action else None,
226227
"choices": list(c.value if isinstance(c, Enum) else c for c in self.choices)
@@ -245,7 +246,7 @@ def from_static_json(
245246
orig_type=data["orig_type"],
246247
default=DEFAULT_PLACEHOLDER
247248
if data["default"] == DEFAULT_PLACEHOLDER
248-
else data["default"],
249+
else json.loads(data["default"]),
249250
help=data["help"],
250251
action=data["action"],
251252
choices=data["choices"],

0 commit comments

Comments
 (0)