-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Adds typing_extensions.OrderedDict
alias, refs #11528
#11533
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
How can I fix it? |
I will ping @JelleZijlstra and @hauntsaninja as both typeshed and mypy experts 🙂 |
Ok, I've got the simpliest repro:
|
Sorry, not sure about this. |
Try messing around with SemanticAnalyzer.prepare_file |
Yes, I should better prepare Line 340 in f316cc2
|
# Built-in class target may not ready yet -- defer. | ||
self.create_alias(tree, target_name, alias, name) | ||
|
||
def add_typing_extension_aliases(self, tree: MypyFile) -> None: |
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.
This mostly duplicates add_builtin_aliases
, can you make it take the aliases as a parameter like you did for the prepare method?
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.
It is a bit different in this part:
if type_aliases_source_versions[alias] > self.options.python_version:
# This alias is not available on this Python version.
continue
name = alias.split('.')[-1]
if name in tree.names and not isinstance(tree.names[name].node, PlaceholderNode):
continue
The thing is: add_builtins_aliases()
is used to refine Partial
types as well. But, with the new method - we don't have this problem. It also checks for versions while working with typing
. But, we do that with typing_extensions
. Question: should we?
So, I've decided to devide them, there's no clear way to unify this logic in my head 😞
Thanks everyone! 🎉 |
Hi, Is this fix already available into the last release of Mypy? I still have an issue with Variable "typing_extensions.OrderedDict" is not valid as a type Regards |
No, this will be available in 0.930 as far as I know. |
I went for
pythoneval
test suite, because all others were very hard to debug / fix.All of them also required
collections.pyi
hacks, so it was not worth it.Closes #11528