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.
In typing spec at: #enum-literal-expansion.
Code below reports
assignment_incompatibilityforxPlayground link
This was first reported against
pyrightbut 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.