Skip to content
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

Add missing value factory for from_dict() #238

Open
evan0greenup opened this issue Jul 8, 2023 · 0 comments
Open

Add missing value factory for from_dict() #238

evan0greenup opened this issue Jul 8, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@evan0greenup
Copy link

Is your feature request related to a problem? Please describe.
When there is missing value in dict, it will raise Error, this is good for majority scenario but sometimes user want to give the attribute with default value for the specific type via default factory callable.

It would be nice to add this support in Config.

Describe the solution you'd like
Add default_factory kwarg in Config which is type dict[type, Callable[[], Any]. the return value of callable is the instance of the key type.

The default value of default_factory is None, which will raise Error when the key is missing.

When the missing value is the type beyond the keys in default_factory, it will also raise Error.

Describe alternatives you've considered
...

Additional context

@evan0greenup evan0greenup added the enhancement New feature or request label Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant