Skip to content

Literal composition #11616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Dreamsorcerer opened this issue Nov 25, 2021 · 2 comments
Closed

Literal composition #11616

Dreamsorcerer opened this issue Nov 25, 2021 · 2 comments

Comments

@Dreamsorcerer
Copy link
Contributor

Dreamsorcerer commented Nov 25, 2021

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")
@sobolevn
Copy link
Member

Related https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html

@brianschubert
Copy link
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.

@brianschubert brianschubert closed this as not planned Won't fix, can't repro, duplicate, stale Dec 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants