Skip to content

Commit 235b2cd

Browse files
authored
fix: validate_model() could be called with other types rather than dict (#14)
Signed-off-by: Michele Dolfi <[email protected]>
1 parent aaf17fe commit 235b2cd

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docling_core/types/doc/document.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ class CCSDocument(
311311
@classmethod
312312
def from_dict(cls, data):
313313
"""Validates and fixes the input data."""
314+
if not isinstance(data, dict):
315+
return data
314316
description_collection = data["description"].get("collection")
315317
if not description_collection:
316318
data["description"].setdefault("collection", {})
@@ -386,6 +388,8 @@ class ExportedCCSDocument(
386388
@classmethod
387389
def from_dict(cls, data):
388390
"""Fix ref in main-text."""
391+
if not isinstance(data, dict):
392+
return data
389393
if data.get("main-text"):
390394
for item in data["main-text"]:
391395
if ref := item.pop("__ref", None):

0 commit comments

Comments
 (0)