Use Optional[T]
for values that may not be present
#163
Labels
enhancement
Requests for new features or improvements.
Optional[T]
for values that may not be present
#163
Motivation
Types assigned to fields like
journal_ref
ordoi
of classResult
doesn't represent them correctly."... if present" comment is typically present. But the type is just
str
.What does "if present" exactly means? Initially, I thought it would be just empty string, because the type is
str
, but in reality it isNone
.Solution
Replace the type annotation for fields that may not be present using
Optional
.Considered alternatives
Well, you can instead return empty string instead of
None
to be complaint with the type, but,Optional
is much cleaner approach.The text was updated successfully, but these errors were encountered: