KEMBAR78
`type[Literal['']]` does not accept `str` as the type · Issue #18196 · python/mypy · GitHub
Skip to content

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

@sobolevn

Description

@sobolevn

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

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions