Skip to content

Literal[True, False] false positives within tuples #11701

Description

@JukkaL

This code generates unexpected errors:

fromtypingimportNamedTuple, Literal, List, TupleC=NamedTuple("C", [("x", Literal[True, False])])
T=Tuple[Literal[True, False]]
# Incompatible types in assignment (expression has type "List[C]", variable has type "List[C]")x: List[C] = [C(True)]
t: T# Incompatible types in assignment (expression has type "List[Tuple[bool]]", # variable has type "List[Tuple[Union[Literal[True], Literal[False]]]]")y: List[T] = [t]

The issue was introduced in #10389.

Marking as high priority since this is a regression.

cc @ethan-leba

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions