Skip to content

Generic constraint inference problem with TypedDict #3610

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

Closed
JukkaL opened this issue Jun 26, 2017 · 0 comments
Closed

Generic constraint inference problem with TypedDict #3610

JukkaL opened this issue Jun 26, 2017 · 0 comments
Assignees
Labels

Comments

@JukkaL
Copy link
Collaborator

JukkaL commented Jun 26, 2017

Mypy doesn't seem to infer constraints correctly for TypedDicts. Example:

from typing import TypeVar, Iterable
from mypy_extensions import TypedDict

T = TypeVar('T')

def f(x: Iterable[T]) -> T: pass

A = TypedDict('A', {'x': int})

a: A
reveal_type(f(a)) # Argument 1 to "f" has incompatible type "A"; expected Iterable[<nothing>]

The f(a) call should be okay and the revealed type should be str. This affects iter() at least.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant