This was broken for certain situations (when the document type was defined in another file, but not in pytorch_ie.documents?). That means that Document.fromdict() was also broken in these situations (but yous should have noticed it because an Exception was thrown). Previously, we relied on field.type, but that is not always a type, but may be a string representation of the type hint. With this PR, we use typing.get_type_hints(cls) if the former returns a string for any of the fields.
This was broken for certain situations (when the document type was defined in another file, but not in
pytorch_ie.documents
?). That means thatDocument.fromdict()
was also broken in these situations (but yous should have noticed it because an Exception was thrown). Previously, we relied onfield.type
, but that is not always a type, but may be a string representation of the type hint. With this PR, we usetyping.get_type_hints(cls)
if the former returns a string for any of the fields.