Skip to content
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

Literal composition #11616

Open
Dreamsorcerer opened this issue Nov 25, 2021 · 1 comment
Open

Literal composition #11616

Dreamsorcerer opened this issue Nov 25, 2021 · 1 comment

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

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

3 participants