-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dynamic default value or factory for function argument #57
Comments
Hey again, @xbanke - This is a great idea, and again, thank you for the detailed example. I haven’t focused much on this issue in the past because the original focus of the decorator was simply to ensure external inputs are the type you expect, but I do see the value here. I’m beginning to compile a list of features for the next minor release - I definitely think this is achievable and worth adding to it. |
I'm Looking forward to that. When will you release the next version? |
Description
Hey, @seandstewart . I have another feature request.
For data model, there is
default_factory
which can be used to set dynamic default value. For function argument, if set the default value as a instance oftypic.Field
, it won't be validated as a default value.datetime.now
as a default_factory is quite common. Every time I have to handle it like this:Especilly when we have many functions with dynamic default value, it would be a problem. Currently, beacuse the default value would not be validated, I defined a Helper class to solve this.
Now we can redefine
foo
like this:By the way, what if the user want to use the key words such as
dict
,schema
,coerce
,strict
and so on, as the function argument or data attribute?The text was updated successfully, but these errors were encountered: