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

TypedDict gets converted into something weird with TypeVar #12609

Closed
Dreamsorcerer opened this issue Apr 17, 2022 · 1 comment
Closed

TypedDict gets converted into something weird with TypeVar #12609

Dreamsorcerer opened this issue Apr 17, 2022 · 1 comment
Labels
bug mypy got something wrong topic-type-form TypeForm might fix this topic-type-variables topic-typed-dict

Comments

@Dreamsorcerer
Copy link
Contributor

Dreamsorcerer commented Apr 17, 2022

class D(TypedDict):
    a: int

T = TypeVar("T")
def t(t: Type[T]) -> T: ...

d = t(D)
reveal_type(d["a"])

The output is Revealed type is "builtins.object*"

If I try to annotate the argument with: args1: D = t(D)
Then I get a weird error: Incompatible types in assignment (expression has type "D", variable has type "D")

It seems that the return type of the function is some modified version of D where all the values have been reduced to object.

Not sure if this might be related to #9003 or #8620.

  • Mypy version used: 0.942
  • Python version used: 3.8/3.9
@AlexWaygood
Copy link
Member

Closing as this is basically a duplicate of #12385 (it has the same root cause, anyhow), but feel free to add a comment to that issue.

@AlexWaygood AlexWaygood added the topic-type-form TypeForm might fix this label Apr 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-type-form TypeForm might fix this topic-type-variables topic-typed-dict
Projects
None yet
Development

No branches or pull requests

2 participants