You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class_Spec:
data=Checker([LIST_OF], LIST_OF=Optional[str])
validate_data_spec({'data': ['str', None]}, _Spec)
# TypeError: field: _Spec.data, reason: ['str', None] is not a spec of <class '__main__._Spec'>, detail: AttributeError('find')
tried with str | None
class_Spec:
data=Checker([LIST_OF], LIST_OF=None|str)
validate_data_spec({'data': ['str', None]}, _Spec)
# TypeError: field: _Spec.data, reason: ['str', None] is not a spec of <class '__main__._Spec'>, detail: AttributeError("'types.UnionType' object has no attribute 'find'")
The text was updated successfully, but these errors were encountered:
I'm not a fan of returning a list of objects which contains different type of data.
But that is not the scope that DSV should consider about.
IMO, I prefer not mixed-using both DSV defined Checks (i.e. STR, NONE, SPEC,...) and Python typing object (i.e. Optional, Dic, Tuple, Any,...). As it could become a bottomless pit in terms of feature supporting,
For example,
Please support Optional against Checker, make
class _Spec:
field = Checker([int], optional=True)
equals to
class _Spec:
field = Optional[Checker([int])]
Besides, the original idea of DSV is to support from python 2.7, it could be a complete different design when Python typing comes into play.
I guess we can start supporting something like
class _Spec:
data = Checker([LIST_OF], LIST_OF=[None, str, SPEC_A, SPEC_B])
Here is a minimum-reproducible code:
tried with
str | None
The text was updated successfully, but these errors were encountered: