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 of expression "Literal['fred']" wrong #17592

Closed
urnest opened this issue Jul 26, 2024 · 2 comments
Closed

type of expression "Literal['fred']" wrong #17592

urnest opened this issue Jul 26, 2024 · 2 comments
Labels
bug mypy got something wrong

Comments

@urnest
Copy link
Contributor

urnest commented Jul 26, 2024

(venv) xju@xjutv:~/mypy$ mypy --version
mypy 1.12.0+dev.e67decb91ea5aacbb1e126463b02d78ded680a90.dirty (compiled: no)

(venv) xju@xjutv:~/mypy$ cat ~/todo/cut.py
from typing import TypeVar, Literal
reveal_type(Literal['fred']) # builtins.object ... should be type[Literal['fred']]

(venv) xju@xjutv:~/mypy$ mypy ~/todo/cut.py
/home/xju/todo/cut.py:2: note: Revealed type is "typing._SpecialForm"
Success: no issues found in 1 source file

... am fixing

@urnest urnest added the bug mypy got something wrong label Jul 26, 2024
@urnest
Copy link
Contributor Author

urnest commented Jul 26, 2024

hmm, I think 1.10 reported builtins.object, but later (as shown in ticket description) reports typing._SpecialForm
... shrug, they are both wrong

@hauntsaninja
Copy link
Collaborator

At runtime, Literal['fred'] is not an instance of type. See also the discussion surrounding TypeForm

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong
Projects
None yet
Development

No branches or pull requests

2 participants