konradhalas / dacite

Simple creation of data classes from dictionaries.
MIT License
1.76k stars 106 forks source link

Add type transform option #32

Closed errx closed 5 years ago

errx commented 5 years ago

Hello. Thank you for this library.

It would be nice to have some type transformation function support. Because in some cases, especially when dealing with dates and other complex objects, this kind of transformations can greatly reduce deserialization code.

konradhalas commented 5 years ago

@errx thank you for your PR :)

Unfortunately, I have to reject it. Generally - it's a good idea and very good implementation, but it also out-of-scope of this project. dacite is not a serialization/deserialization library. There are so many good libs, like DRF or marshmallow, which can handle this case, and I don't want double this functionality in dacite. You should combine such lib with dacite.

I know - dacite has right now such options like transform or cast. TBH probably I will drop them in 1.0 release. My main goal is to simplify creation of data classes from dicts - how you will process such dict beforehand is a different story.

Anyway, once again thank you for your PR and thank you that you are using dacite.

konradhalas commented 5 years ago

@errx well, I changed my mind :) I will implement this feature. Please check #38 for more info.

If you want to provide new PR it will be awesome, but TBH I have to refactor a few things, so maybe it will be easier to wait a little bit.