Skip to content

Literal composition #11616

Closed as not planned
Closed as not planned

Description

@Dreamsorcerer

Could be nice to support composition of literals, so that something like this type checks correctly:

from typing import Literal

def page(page: Literal["p1", "p2"]): ...

def foo(num: Literal["1", "2"]):
    page(f"p{num}")
    page("p" + num)
    page("p" + "1")

Activity

  1. sobolevn commented on Nov 26, 2021

    @sobolevn
    Member
  2. brianschubert commented on Dec 8, 2024

    @brianschubert
    Collaborator

    Closing as duplicate of #11990, which was opened later but has more discussion and seems to be the canonical issue linked to by other issues and PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions