konradhalas / dacite

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

Fix Type_hooks not applied to InitVar fields #158 #172

Closed SzymonSwic closed 1 year ago

SzymonSwic commented 2 years ago

Hi, this is my proposal for fix #158

My idea is to extract types from InitVars for dataclass type_hints, as type_hint determines target type for value transformation. Type_hook never triggers if target type is InitVar.

konradhalas commented 2 years ago

@SzymonSwic please check CI errors - it looks that black is not happy about your code formatting ;)

konradhalas commented 1 year ago

@SzymonSwic once again thank you for your PR. I decided to fix it in a little bit different way - https://github.com/konradhalas/dacite/commit/a440f2f0419d13f0fd0eb0f19f761984e455c4ba