ArneBinder / pytorch-ie

PyTorch-IE: State-of-the-art Information Extraction in PyTorch
MIT License
75 stars 7 forks source link

fix `Document.annotation_fields()` #384

Closed ArneBinder closed 11 months ago

ArneBinder commented 11 months ago

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.