Skip to content
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

Parameters for a TypedDict don't show type on hover #3569

Closed
rchiodo opened this issue Nov 3, 2022 · 7 comments
Closed

Parameters for a TypedDict don't show type on hover #3569

rchiodo opened this issue Nov 3, 2022 · 7 comments
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version P2

Comments

@rchiodo
Copy link
Contributor

rchiodo commented Nov 3, 2022

Note: if you are reporting a wrong signature of a function or a class in the standard library, then the typeshed tracker is better suited for this report: https://github.com/python/typeshed/issues.

Describe the bug
Hover for TypedDicts init does not compute the type

To Reproduce
Steps to reproduce the behavior.

image

VS Code extension or command-line
VS Code Extension

Additional context
Add any other context about the problem here.

@erictraut
Copy link
Contributor

erictraut commented Nov 3, 2022

@rchiodo, can you please paste the code in text form? It's inconvenient to retype from a screen shot.

@tuchandra
Copy link

tuchandra commented Nov 3, 2022

I don't think your code is correct. TypedDict is not initialized like a class, even though it looks like one. This is completely wrong, thanks Eric.

The below should work and autocomplete/hover correctly—

y: Movie2 = {"name": "foo", "year": 4}

# alternative
y: Movie2 = dict(name="foo", year=4)

@erictraut
Copy link
Contributor

@tuchandra, the constructor call in the screen shot above is legal for a TypedDict. The two forms you provided are also supported.

@erictraut
Copy link
Contributor

Here's the code in text form:

from typing import TypedDict

class Movie2(TypedDict):
    name: str
    year: int

y = Movie2(name='foo', year=4)

print(y['name'])

@erictraut
Copy link
Contributor

I agree that the hover text in this case could be improved. Since this is a language server issue, not a core type-checking issue, I'm going to transfer it to pylance-release.

@erictraut erictraut transferred this issue from microsoft/pyright Nov 3, 2022
@judej judej added bug Something isn't working P2 and removed triage-needed labels Nov 3, 2022
erictraut pushed a commit to microsoft/pyright that referenced this issue Nov 6, 2022
@erictraut
Copy link
Contributor

This will be addressed in the next release of pyright and a future release of pylance.

@erictraut erictraut added the fixed in next version (main) A fix has been implemented and will appear in an upcoming version label Nov 6, 2022
@rchiodo rchiodo closed this as completed Nov 10, 2022
@rchiodo
Copy link
Contributor Author

rchiodo commented Nov 10, 2022

This issue has been fixed in prerelease version 2022.11.21, which we've just released. You can find the changelog here: CHANGELOG.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working fixed in next version (main) A fix has been implemented and will appear in an upcoming version P2
Projects
None yet
Development

No branches or pull requests

4 participants