Skip to content

Commit

Permalink
Don't try to encode unknown types
Browse files Browse the repository at this point in the history
  • Loading branch information
gsakkis committed Dec 26, 2023
1 parent ba7b096 commit 762acab
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions beanie/odm/utils/encoder.py
Expand Up @@ -135,17 +135,7 @@ def encode(self, obj: Any) -> Any:
if isinstance(obj, Iterable):
return [self.encode(value) for value in obj]

errors = []
try:
data = dict(obj)
except Exception as e:
errors.append(e)
try:
data = vars(obj)
except Exception as e:
errors.append(e)
raise ValueError(errors)
return self.encode(data)
raise ValueError(f"Cannot encode {obj!r}")

def _iter_model_items(
self, obj: pydantic.BaseModel
Expand Down

0 comments on commit 762acab

Please sign in to comment.