void () { doTestByText(""" from typing import TypedDict, Literal, Union class Movie(TypedDict): name: str year: int def get_value(movie: Movie, key: Literal['year', 'name']) -> Union[int, str]: return movie[key] def get_value(movie: Movie, key: Literal['name']) -> Union[int, str]: return movie[key] def get_value(movie: Movie, key: Literal['name1']) -> Union[int, str]: return movie[<warning descr="TypedDict \\"Movie\\" has no key 'name1'">key</warning>] def get_value(movie: Movie, key: Literal['year', 42]) -> Union[int, str]: return movie[<warning descr="TypedDict key must be a string literal; expected one of ('name', 'year')">key</warning>] def get_value(movie: Movie, key: Literal['year', 'name1', '42']) -> Union[int, str]: return movie[<warning descr="TypedDict \\"Movie\\" has no keys ('name1', '42')">key</warning>] def get_value(movie: Movie, key: Literal[42]) -> Union[int, str]: return movie[<warning descr="TypedDict key must be a string literal; expected one of ('name', 'year')">key</warning>]"""); }