Skip to content

conformance: remove incorrect error from Literal test#2264

Closed
KotlinIsland wants to merge 1 commit intopython:mainfrom
KotlinIsland:literal
Closed

conformance: remove incorrect error from Literal test#2264
KotlinIsland wants to merge 1 commit intopython:mainfrom
KotlinIsland:literal

Conversation

@KotlinIsland
Copy link
Copy Markdown
Contributor

from typing import Literal, Union


a: dict[(int, str)]  # valid
b: Union[(int, str)]  # valid
c: Literal[(1, 2)]  # invalid???

@carljm
Copy link
Copy Markdown
Member

carljm commented Apr 19, 2026

This is specifically mandated in the spec, with rationale, so it shouldn't be changed in the conformance suite unless the spec text is updated.

The rationale for forbidding this is that it's unclear if the user is trying to express Literal[1, 2] or tuple[Literal[1], Literal[2]]. I think this rationale makes sense, and there's nothing significant to be gained by supporting this syntax.

@KotlinIsland KotlinIsland deleted the literal branch April 20, 2026 00:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants