hundreds-father-404
03/13/2020, 3:25 PMas a practical matter is it true that lazy is only important for fields that point to files?Not necessarily. Many fields have no validation/hydration, but even simple fields like
timeout
have validation to ensure, for example, that the int is > 0. Or compatibility
has lightweight hydration by calling ensure_str_list
because it can be Union[str, Iterable[str]]
.
In V1, we eagerly validate everything. In V2 TargetAdaptors, we don’t validate anything, except for a few special cases. A key design goal of the Target API was to provide a unified mechanism for validation/hydration of fields. Sometimes that hydration is very expensive, and sometimes we literally just return the original `raw_value`; so, we need in some cases to have lazy hydration. Because we wanted a unified mechanism and unified concept, that means that with the Target API all fields are lazy to avoid special casing the few fields that are very expensive to hydrate.