Skip to content

Basilisk fails union-of-members/enum equivalency in some case. #374

Description

@tapetersen

In typing spec at: #enum-literal-expansion.

Likewise, a type checker should treat a complete union of all literal members as equivalent to the enum type:

Code below reports assignment_incompatibility for x

class Answer(enum.Enum):
    Yes = 1
    No = 2

def test4(a: Answer) -> None:
    x: Literal[Answer.Yes, Answer.No] = a
    assert_type(a, Literal[Answer.Yes, Answer.No])

Playground link

This was first reported against pyright but since this was a hole in the conformance suite as well and I opened an issue and PR about it here and discovered basilisk also failed in 1 case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions