-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Allow class-based NamedTuple syntax in semantic analyzer for stubs in pre-3.6 mode #3464
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
Had this come up in python/typeshed#3278. |
This seems to be the relevant code (in def check_namedtuple_classdef(
self, defn: ClassDef) -> Optional[Tuple[List[str], List[Type], Dict[str, Expression]]]:
"""Parse and validate fields in named tuple class definition.
Return a three tuple:
* field names
* field types
* field default values
or None, if any of the types are not ready.
"""
if self.options.python_version < (3, 6):
self.fail('NamedTuple class syntax is only supported in Python 3.6', defn)
return [], [], {}
... Also, there is Anybody want to write a PR? |
Previously, it was not supported in stubs when checking in Python 2.7 or 3.5 mode. Closes: python#3464
PR in #7646. |
Previously, it was not supported in stubs when checking in Python 2.7 or 3.5 mode. Closes: #3464
Do we know if this is supported by type checkers other than mypy? |
We checked this in python/typeshed#3321 and pytype, pyre, and pyright, PyCharm, and the Microsoft Language Server for Python all support this. |
See python/typeshed#1336 (comment)
Not very important, but would be nice if stubs could use
instead if
The text was updated successfully, but these errors were encountered: