-
Notifications
You must be signed in to change notification settings - Fork 768
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
Bug when function return is typing.Type[] #821
Comments
Thanks for the clear and concise bug report. This will be fixed in the next release of pylance. |
Thank you for the super-quick fix! |
This issue has been fixed in version 2021.1.1, which we've just released. You can find the changelog here: https://github.com/microsoft/pylance-release/blob/main/CHANGELOG.md#202111-13-january-2021 |
The problem still happens if the inferred type is |
This is the intended behavior. If you change your code to indicate that the return type is
|
I'm mainly talking about the case of having type checking off, here. from typing import Union
def get_str_or_int() -> Union[str, int]:
pass
x = get_str_or_int()
x.upper() # right now "upper" is tokenized and "go to definition" works on it |
Environment data
Expected behaviour
Let's say I have a function called
get_cls
and I explicitly specify it's return type to beType[Example]
(assume it uses importlib to get the actual class, so explicit hint is needed), and let's sayExample
has some member callednum
.If I type
get_cls().num
I should findnum
in the intellisense list, and it should get a semantic token color, and pressing F12 (go to definition) onnum
should work. It should be identical to typingExample.num
directly.Actual behaviour
What happens is that
num
shows up in intellisense, but it doesn't get any semantic tokens, and F12 fails.Doing the same for
Example.num
works as expected.Code Snippet / Additional information
Screenshot showing "go to definition" error:
Notice the error and the lack of semantic color.
Full Code Sample:
Removing the
Type[Example]
return hint fixes the issue, but only because the function is very basic.The text was updated successfully, but these errors were encountered: