-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Support PEP 675 (LiteralString) #12554
Comments
Hmm, an alternative idea would be if typing_extensions/typing had feature flags like, typing.PEP_675_SUPPORTED then typeshed could add to typing_extensions.pyi, if not typing.PEP_675_SUPPORTED:
LiteralString = str
else:
LiteralString: _SpecialForm and each type checker would have a list of recognized typing feature flags. For this specific case my hopeful guess is work involved isn't large but main reason I'd be interested in this is to make it possible to have stuff like, if typing.PEP_646_SUPPORTED:
def foo(...):
...
else:
def foo(...):
... where I'm guessing even basic support will be harder. I'm assuming most feature flags would correspond to one typing pep. |
@hmc-cs-mdrissi, that might be nice, but we'd require agreement from all major type checkers to do something like that (such proposals should be discussed in the https://github.com/python/typing issue tracker rather than this one). For now, @JelleZijlstra's suggestion is probably easier. |
Linking #12554 Co-authored-by: hauntsaninja <>
Hello, just to let you know, I have introduced I would like to throw at you an use case we could be interested in: to use mypy as a library to verify at import time or runtime that the user is not doing anything untoward. If you think that something of that sort might happen, please keep us informed. Thank you! |
Note that mypy has currently reverted python/typeshed#7725 in its vendored copy of typeshed (#13093, #13091) in order to avoid some inference regressions (#12982 (comment)). This is fine because mypy currently does not actually support LiteralString. |
Good day! I'm wondering if there is an update regarding the inclusion of LiteralString in mypy? Thanks! |
We should support
LiteralString
from PEP 675 (https://peps.python.org/pep-0675/).As a first step, I would suggest changing the semantic analyzer to treat LiteralString simply as an alias for
str
. That's not correct, but it will be enough to enable third-party libraries and typeshed to start using LiteralString.The text was updated successfully, but these errors were encountered: