-
Notifications
You must be signed in to change notification settings - Fork 110
Support generics, forward references and case conversion #269
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
Conversation
|
On my side, the last benchmark is highlighted in red. Is this a problem? |
Sometimes we might want to trade a small performance hit for highly enhanced functionality, right? But some of the tests still fail, some due to the usage of newer Python functionalities in Python 3.7 and 3.8 environments, some seem to be legit issues with the code. You can try to run tests on different Python versions locally, and I'll try to also look into it in the upcoming days. Sorry for that, a bit busy right now. But definitely let's push this forward so we can finally merge it into the repo. @konradhalas What do you think about the |
Agreed. Especially since the extra compute caused by my changes only needs to be done once as it is wrapped by lru_cache.
For my personal project, I could not use dacite without this feature: my UI expects to receive camelCase keys. Without this feature, you have to loop over the dict twice, which is a bummer wrt performance. Note that convert_keys is a config parameter, so it's optional, and it is not a change that makes the dacite code more difficult to maintain as it hooks in on basically one line of code in the core function. |
|
Tested locally for
Only the last benchmark is still red. |
|
@avlonder Thanks for the work, we're almost there. There's just two small things. Please take a look at the PR here: #271 and see my two latest commits.
Once we have these two fixed we can finally merge and make a new release! 🎉 |
Ok, looked at it and applied the typing fixes. This generics.get(hint, hint) was a safety measure to fall back to the original TypeVar, but this fallback is AFAIK never hit in my project, so I just discarded it, making the code pass the type checker: if the TypeVar does not occur in the generics dict for a case I was overlooking, the original dacite would have failed anyways, so it actually made no sense to introduce the fallback. |
|
Oh wait, no: the original dacite would have worked in case config.check_types = False. Let me revert that change... |
|
Ready :) |
|
Thanks a tonne @avlonder, I've merged your PR into a separate branch in order to avoid more back-and-forts, will look into why |
No description provided.