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

type[Literal['']] does not accept str as the type #18196

Open
sobolevn opened this issue Nov 26, 2024 · 1 comment
Open

type[Literal['']] does not accept str as the type #18196

sobolevn opened this issue Nov 26, 2024 · 1 comment
Labels
bug mypy got something wrong topic-literal-types

Comments

@sobolevn
Copy link
Member

I am not even sure that type[Literal] is correct :)

from typing import Literal

def a(x: type[Literal['a']]):
    reveal_type(x)
    
a(str)  # Argument 1 to "a" has incompatible type "type[str]"; expected "type[Literal['a']]"  [arg-type]

https://mypy-play.net/?mypy=latest&python=3.12&gist=6b8a1d7e6f98c64e7f751c58d356bf16

@sobolevn sobolevn added bug mypy got something wrong topic-literal-types labels Nov 26, 2024
@JelleZijlstra
Copy link
Member

type[Literal[...]] is invalid and should be rejected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-literal-types
Projects
None yet
Development

No branches or pull requests

2 participants