| 1 |
from typing import Annotated, Any |
| 2 |
|
| 3 |
import bson |
| 4 |
import pydantic |
| 5 |
|
| 6 |
|
| 7 |
def _to_bson_binary(value: Any) -> bson.Binary: |
| 8 |
return value if isinstance(value, bson.Binary) else bson.Binary(value) |
| 9 |
|
| 10 |
|
| 11 |
BsonBinary = Annotated[bson.Binary, pydantic.PlainValidator(_to_bson_binary)] |