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
{{ message }}
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.
Is allow_none a good name? Traditionally these types of fields would be called "optional", but this may be interpreted as "you don't need to supply a value"(which is what default= does), not necessarily as "you can put None in there"
Should allow_none imply default=None?
Do we want to limit this just for None values? It may be useful to also allow tokens. Maybe something like:
I'm not sure about the motivation.
It seems that if you're reading from some foreign source, and looking to create a TypedStruct from foreign data, there should be code that converts such None/MIN/MAX/AUTO into the appropriate types.
Or, Field should allow multiple types: ts.Field({str, NoneType, AUTO}). I don't think allow is very elegant...
I'd say - it as a road to everything a dict hell, make bunch great again.
typed should be typed, no optional types, if no value supplied(i.e kwargs unpacking from external source) and default is set - use default for initialising
Might also allow DEFAULT token, which should be used in typed functions definitions, which later chained to struct creation
This will indicate that default should be used. Plain None == exception
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
TypedStruct fields are forcing a type, but sometimes we want to explicitly allow None values:
Questions:
allow_none
a good name? Traditionally these types of fields would be called "optional", but this may be interpreted as "you don't need to supply a value"(which is whatdefault=
does), not necessarily as "you can put None in there"allow_none
implydefault=None
?None
values? It may be useful to also allow tokens. Maybe something like:@koreno?
The text was updated successfully, but these errors were encountered: