Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit e8132e3

Browse files
MarkKoz64json
authored andcommitted
Dump and load args as JSON when creating a command
This ensures the args can be serialized and also creates copies of all args.
1 parent df4d5f4 commit e8132e3

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

algorithm_visualizer/commander.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import string
23
from typing import Any, Dict, List, Optional, Union
34

@@ -20,10 +21,11 @@ def __init__(self, *args):
2021

2122
@classmethod
2223
def _command(cls, key: Optional[str], method: str, *args: Union[Serializable, Undefined]):
24+
args = tuple(a for a in args if not isinstance(a, Undefined))
2325
cmd = {
2426
"key": key,
2527
"method": method,
26-
"args": tuple(a for a in args if not isinstance(a, Undefined))
28+
"args": json.loads(json.dumps(args))
2729
}
2830
cls.commands.append(cmd)
2931

0 commit comments

Comments
 (0)