Skip to content

Commit

Permalink
fix several bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxDall committed Feb 12, 2025
1 parent 98dee2c commit a1112a8
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/fundus/scraping/article.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from fundus.logging import create_logger
from fundus.parser import ArticleBody, Image
from fundus.scraping.html import HTML
from fundus.utils.serialization import JSONVal
from fundus.utils.serialization import JSONVal, is_jsonable

logger = create_logger(__name__)

Expand Down Expand Up @@ -133,7 +133,9 @@ def serialize(v: Any) -> JSONVal:
return v.serialize() # type: ignore[no-any-return]
elif isinstance(v, datetime):
return str(v)
raise TypeError(f"Attribute {attribute!r} of type {type(v)!r} is not JSON serializable")
elif not is_jsonable(v):
raise TypeError(f"Attribute {attribute!r} of type {type(v)!r} is not JSON serializable")
return v # type: ignore[no-any-return]

serialization: Dict[str, JSONVal] = {}
for attribute in attributes:
Expand All @@ -144,7 +146,7 @@ def serialize(v: Any) -> JSONVal:
if isinstance(value, list):
serialization[attribute] = [serialize(item) for item in value]
else:
serialization[attribute] = value
serialization[attribute] = serialize(value)

return serialization

Expand Down

0 comments on commit a1112a8

Please sign in to comment.