Skip to content

False negative when using a TypeVar bound to a TypedDict #5708

@erictraut

Description

@erictraut

The following code should produce a type error.

from typing import Generic, TypeVar, TypedDict

class TD1(TypedDict):
    a: str

T = TypeVar("T", bound=TD1)

class G(Generic[T]):
    def method1(self) -> T:
        return {"a": ""} # No error!

This is related to mypy issue python/mypy#11812.

Metadata

Metadata

Assignees

No one assigned

    Labels

    addressed in next versionIssue is fixed and will appear in next published versionbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions