File tree 2 files changed +4
-11
lines changed
2 files changed +4
-11
lines changed Original file line number Diff line number Diff line change @@ -135,17 +135,7 @@ def encode(self, obj: Any) -> Any:
135
135
if isinstance (obj , Iterable ):
136
136
return [self .encode (value ) for value in obj ]
137
137
138
- errors = []
139
- try :
140
- data = dict (obj )
141
- except Exception as e :
142
- errors .append (e )
143
- try :
144
- data = vars (obj )
145
- except Exception as e :
146
- errors .append (e )
147
- raise ValueError (errors )
148
- return self .encode (data )
138
+ raise ValueError (f"Cannot encode { obj !r} " )
149
139
150
140
def _iter_model_items (
151
141
self , obj : pydantic .BaseModel
Original file line number Diff line number Diff line change @@ -283,6 +283,9 @@ class DocumentWithCustomFiledsTypes(Document):
283
283
tuple_type : Tuple [int , str ]
284
284
path : Path
285
285
286
+ class Settings :
287
+ bson_encoders = {Color : vars }
288
+
286
289
if IS_PYDANTIC_V2 :
287
290
model_config = ConfigDict (
288
291
arbitrary_types_allowed = True ,
You can’t perform that action at this time.
0 commit comments