You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is it possible to get the keys that were not used during a call to structure(input_dict, SomeClass)?
One way would be to use forbid_extra_keys to get the names of these extra keys, but then you would have to run structure a second time if you still want to use the structured data
I'm on paternity leave currently so my availability is dependent on how well our baby sleeps 😥
I was going to ask what do you want to do with the extra keys, but I see the idea is to stick them into an attribute?
Your approach is pretty solid. I think you can pull out the first two lines out of structure into preprocess to optimize a little.
If you want to support overrides, I think you can use converter.get_structure_hook instead of make_dict_structure_func and look at hook.overrides - the generated hooks will have their overrides stored there. If present, this attribute can be examined and used to adapt your logic.
Activity
kellerza commentedon Sep 14, 2024
For now I'm using this.
It's based on the fallback_field example in the docs. It support an attrs alias but not the overrides
Tinche commentedon Sep 14, 2024
Hello,
I'm on paternity leave currently so my availability is dependent on how well our baby sleeps 😥
I was going to ask what do you want to do with the extra keys, but I see the idea is to stick them into an attribute?
Your approach is pretty solid. I think you can pull out the first two lines out of
structureintopreprocessto optimize a little.If you want to support overrides, I think you can use
converter.get_structure_hookinstead ofmake_dict_structure_funcand look athook.overrides- the generated hooks will have their overrides stored there. If present, this attribute can be examined and used to adapt your logic.