Closed InAnYan closed 4 months ago
Types assigned to fields like journal_ref or doi of class Result doesn't represent them correctly.
journal_ref
doi
Result
"... if present" comment is typically present. But the type is just str.
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 is None.
None
Replace the type annotation for fields that may not be present using Optional.
Optional
Well, you can instead return empty string instead of None to be complaint with the type, but, Optional is much cleaner approach.
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.