This problem was reported by @devolt5. It seems to be dataclasses_json-related:
File "env/lib/python3.12/site-packages/dataclasses_json/core.py", line 318, in _decode_generic
res = collection_type(xs)
^^^^^^^^^^^^^^^^^^^
TypeError: 'typing.TypeAliasType' object is not callable
These tests should demonstrate the problem:
# TextLine: works
def test_textline_serialization_roundtrip() -> None:
tl = TextLine(id="tl-id", coords=Coords.parse("1,2 3,4"), text="foo bar")
assert TextLine.from_dict(tl.to_dict()) == tl
# TextRegion: fails
def test_textregion_serialization_roundtrip() -> None:
tr = TextRegion(
id="tr-id",
coords=Coords.parse("1,2 3,4"),
textlines={
"tl-1": TextLine(id="tl-1", coords=Coords.parse("1,2 3,4"), text="foo")
},
)
assert TextRegion.from_dict(tr.to_dict()) == tr
# TextRegion: fails
def test_page_serialization_roundtrip() -> None:
pa = Page(
image_filename="a.jpg",
regions={
"tr-1": TextRegion(
id="tr-1",
coords=Coords.parse("1,2 3,4"),
textlines={
"tl-1": TextLine(
id="tl-1", coords=Coords.parse("1,2 3,4"), text="foo"
)
},
)
},
)
assert Page.from_dict(pa.to_dict()) == pa
This problem was reported by @devolt5. It seems to be
dataclasses_json-related:These tests should demonstrate the problem: