MCPcopy Create free account
hub / github.com/catboost/catboost / _serialize

Function _serialize

library/python/testing/yatest_lib/external.py:67–82  ·  view source on GitHub ↗
(val, _)

Source from the content-addressed store, hash-verified

65 :param value: object to be serialized
66 """
67 def _serialize(val, _):
68 if val is None:
69 return val
70 if isinstance(val, six.string_types) or isinstance(val, bytes):
71 return tools.to_utf8(val)
72 if isinstance(val, enum.Enum):
73 return str(val)
74 if isinstance(val, six.integer_types) or type(val) in [float, bool]:
75 return val
76 if is_external(val):
77 return dict(val)
78 if isinstance(val, (date, datetime)):
79 return repr(val)
80 if is_coroutine(val):
81 return None
82 raise ValueError("Cannot serialize value '{}' of type {}".format(val, type(val)))
83 return apply(_serialize, value, apply_to_keys=True)
84
85

Callers

nothing calls this directly

Calls 8

isinstanceFunction · 0.85
is_externalFunction · 0.85
dictClass · 0.85
reprFunction · 0.85
is_coroutineFunction · 0.85
strClass · 0.50
typeClass · 0.50
formatMethod · 0.45

Tested by

no test coverage detected