Make a few changes to the Optional filter:
- If
self.default is callable, return self.default().
- Add an optional parameter to the initializer called
is_factory that can override this behavior.
Examples:
>>> f.Optional(default=0).apply(None)
0
>>> f.Optional(default=dict).apply(None)
{}
>>> f.Optional(default=dict, is_factory=False).apply(None)
<class 'dict'>
Make a few changes to the
Optionalfilter:self.defaultis callable, returnself.default().is_factorythat can override this behavior.Examples: