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
Merge typed_ast back into CPython #79947
Comments
(This started at https://discuss.python.org/t/merge-typed-ast-back-into-cpython/377. It's somewhat related to https://bugs.python.org/issue33337.) I now have a thorough understanding of what typed_ast does, and I think it would be straightforward to port it upstream. We’d need to define two new tokens to represent By default, I could produce a PR with this in a few days (having just gone over most of the process for porting typed_ast from 3.6 to 3.7). There’s one more feature I’d like to lobby for – a feature_version flag that modifies the grammar slightly so it resembles an older version of Python (going back to 3.4). This is used in mypy to decouple the Python version you’re running from the Python version for which you’re checking compatibility (useful when checking code that will be deployed on a system with a different Python version installed). I imagine this would be useful to other linters as well, and the implementation is mostly manipulating whether In the next few days I will produce a PR so people can see for themselves. In https://discuss.python.org/t/merge-typed-ast-back-into-cpython/377/17, Łukasz offered to merge my PR. |
Seems also related to https://bugs.python.org/issue24119 with python2 / python3.5 (hopefully) rapidly falling off in usage I would assume the specialized treatment of Though I guess there's still |
You’d be surprised how tenacious old versions are. Anywa, I am working on this on my copious spare time — you can follow my progress at https://github.com/gvanrossum/cpython/tree/ast-type-comments?files=1 . |
heh that's true, at my last job we finally got rid of python2.6 in 2016 :'( anyway -- I don't mean to discourage this, definitely seems valuable to the maintenance of mypy! |
The PR is ready for reviews now. |
Also the tests now all pass; for now I am happy with the solution I found for the indentation error (see #11645 (comment)). |
I have some follow-up wishes but I'll create a new issue. |
I don't see anything in What's New in Python 3.8?: Would it be possible to document the change somewhere? |
Most of these things are in the docs for ast module. But indeed none of static typing related features have been added to What's New. I have an item on mypy todo list to add four typing PEPs plus new AST features (also adding |
Typo: "mypy todo list" should be "my todo list" :-) |
I'll create a PR that updates the What's New docs with news about all of these. |
What will happen with Python 4? Why not using "full" Python version like (3, 4) or 0x304? |
I don't think Python 4 is just around the corner, so I prefer to kick that problem down the road. I'm sure we can come up with a sufficiently backwards-compatible API. (I'd prefer not to go the hex route, because printing the value would show as 52, which is pretty meaningless.) |
I propose to replace 4 with (3, 4) to be more future-proof. This version format is already used by sys.version_info for example. |
But this is the format currently used by typed_ast. I think it would just cause a cascade of annoying failures for tools that switch between typed_ast and the 3.8 version of ast. Such as mypy. |
typed_ast is a 3rd party project. But here we are talking about Python stdlib. If a project moves from typed_ast to stdlib ast, IMHO it should be quite easy to replace 4 with (3, 4), especially if 4 raises an error, no? IMHO it's a good opportunity to fix it. I would prefer to not have to batch many backward incompatible changes into Python 4... |
Thanks for taking care of this!--Guido (mobile) |
I created bpo-37253: "PyCompilerFlags got a new cf_feature_version field". |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: