MCPcopy Create free account
hub / github.com/deepseek-ai/DeepSpec / CustomJSONEncoder

Class CustomJSONEncoder

deepspec/utils/config.py:63–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61
62
63class CustomJSONEncoder(json.JSONEncoder):
64 def default(self, obj):
65 if isinstance(obj, FunctionType):
66 return f"<function {obj.__name__}>"
67 if isinstance(obj, type):
68 return f"<class '{obj.__name__}'>"
69 if isinstance(obj, torch.dtype):
70 return str(obj)
71 if isinstance(obj, Path):
72 return str(obj)
73 if isinstance(obj, ConfigNode):
74 return config_to_plain_dict(obj)
75 if isinstance(obj, (Namespace, SimpleNamespace)):
76 return vars(obj)
77 return super().default(obj)
78
79
80def _parse_scalar(value):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected