Adds typing_extensions.OrderedDict alias, refs #11528 - #11533
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.
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.
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):
continueThe 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 typeRegards |
|
No, this will be available in 0.930 as far as I know. |
I went for
pythonevaltest suite, because all others were very hard to debug / fix.All of them also required
collections.pyihacks, so it was not worth it.Closes #11528