-
-
Notifications
You must be signed in to change notification settings - Fork 458
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
Fix mypy cache of WithAnnotation types #725
Conversation
Thanks a lot for the research! I will also try to see what we can do here. |
It seems like my hack with making type names include Unfortunately I don't have time to look at this at the moment. |
Is there any update here or a plan to fix this? The |
That was implemented in that PR, I rebased it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like a solid hack 😆
Thanks, let's try this out.
I'm still having problems with the caching of |
Here is a slightly redacted trace if it helps:
|
I'm also still having this issue with on version 1.13.0 |
This reverts commit 3f340c9.
TypeError: Object of type AnyType is not JSON serializable
#700This is a result of my research of that issue, the fix works for my projects but introduces other problems.
The fix is based on assumption that metadata may consist only of primitives, the fastest way to serialize dict of object is to use pickle, so I just pickle/unpickle metadata on set/get.
After that fix another problem was found, mypy doesn't support lookups of names with generics:
The reason is https://github.com/python/mypy/blob/d1d431630d967923a9562b4dff436a509c2acb8b/mypy/lookup.py#L31 splits by '.' inside generic
[...]
. See how it complaints "Cannot find component'WithAnnotations[project
" while it should search forWithAnnotations[project.Model, TypedDict({'remind_after': Any, 'remind_before': Any})]
.That problem was solved by replacing dots with
__
but I believe that will prevent users to write their ownWithAnnotations
typings...Having said that I don't expect that PR to be merged in current state.