Skip to content

Commit

Permalink
fix: validate_model() could be called with other types rather than dict
Browse files Browse the repository at this point in the history
Signed-off-by: Michele Dolfi <[email protected]>
  • Loading branch information
dolfim-ibm committed Sep 6, 2024
1 parent aaf17fe commit b6921a7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions docling_core/types/doc/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ class CCSDocument(
@classmethod
def from_dict(cls, data):
"""Validates and fixes the input data."""
if not isinstance(data, dict):
return data
description_collection = data["description"].get("collection")
if not description_collection:
data["description"].setdefault("collection", {})
Expand Down Expand Up @@ -386,6 +388,8 @@ class ExportedCCSDocument(
@classmethod
def from_dict(cls, data):
"""Fix ref in main-text."""
if not isinstance(data, dict):
return data
if data.get("main-text"):
for item in data["main-text"]:
if ref := item.pop("__ref", None):
Expand Down

0 comments on commit b6921a7

Please sign in to comment.