-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Comments
|
>>> from typing import Literal
... class A(str):
... def __new__(cls, /) -> Literal["a"]:
... return super().__new__(cls, "a")
...
>>> A()
'a' |
@jorenham I'm not sure what point you are making. |
Wow that was a quick response 😋.
|
of course |
Isn't |
|
I think it's more accurate to describe it as a refinement type, i.e. a |
|
It is syntactic sugar for |
yes, which doesn't describe an instance of |
I am not even sure that
type[Literal]
is correct :)https://mypy-play.net/?mypy=latest&python=3.12&gist=6b8a1d7e6f98c64e7f751c58d356bf16
The text was updated successfully, but these errors were encountered: