MCPcopy Index your code
hub / github.com/Textualize/textual / encode

Function encode

src/textual/_binary_encode.py:148–164  ·  view source on GitHub ↗

Recursively encode data. Args: datum: Data suitable for encoding. Raises: TypeError: If `datum` is not one of the supported types. Returns: Encoded data bytes.

(datum: object)

Source from the content-addressed store, hash-verified

146 }
147
148 def encode(datum: object) -> bytes:
149 """Recursively encode data.
150
151 Args:
152 datum: Data suitable for encoding.
153
154 Raises:
155 TypeError: If `datum` is not one of the supported types.
156
157 Returns:
158 Encoded data bytes.
159 """
160 try:
161 decoder = ENCODERS[type(datum)]
162 except KeyError:
163 raise TypeError("Can't encode {datum!r}") from None
164 return decoder(datum)
165
166 return encode(data)
167

Callers 4

encode_listFunction · 0.85
encode_tupleFunction · 0.85
encode_dictFunction · 0.85
dumpFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…