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)
| 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 |
no outgoing calls
no test coverage detected
searching dependent graphs…