Skip to content

Literal composition #11616

@Dreamsorcerer

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")

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions