-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Literal
support for typeshed
#2913
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
Comments
It would probably help if PEP 586 was accepted. :-) That's waiting for me to petition the Python Steering Council to make me the BDFL-Delegate and then for me to review it. I'm behind on PEP reviews, and it's a long PEP, and IIRC @Michael0x2a is still hoping to finesse the draft. (And the implementation, e.g. he's working on support for enums.) And we should have some public discussion on [email protected]. But I have no doubt that it will be accepted more or less as it currently stands. In the meantime is there a way to write
so that in type checkers other than mypy, it comes down to |
Maybe we should standardize something like if MYPY:
foo = Literal[42] and similar for other type checkers, i.e. |
But how would the other checkers know to ignore code inside |
I am not sure, there are several options. For example, we can define a special constant |
This way people can probably even try to simplify migration between type checkers, or use multiple type checkers if they disagree on some details. |
For pytype, mapping My concern about |
Per recent thread on typing-sig, pytype doesn't yet support Literal but is OK with its use in stubs and won't error on it. Pyre and Mypy both support it. So I guess the only other blocker here is to make sure it won't cause problems for PyCharm? @vlasovskikh ? |
Literals are now accepted per discussion on typing-sig. |
@carljm PyCharm will support Literal in future versions, it's OK to use them in Typeshed. |
This has come up a few times now. When/how do we want to support literals? To make an informed decision, we should know which of our important users already support literals or plan to support them with the next version.
The text was updated successfully, but these errors were encountered: