Skip to content
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 3.7 #60

Closed
Mattwmaster58 opened this issue Apr 23, 2018 · 22 comments
Closed

Support 3.7 #60

Mattwmaster58 opened this issue Apr 23, 2018 · 22 comments
Assignees

Comments

@Mattwmaster58
Copy link

@Mattwmaster58 Mattwmaster58 commented Apr 23, 2018

Currently python 3.7 is unsupported. Is it to early to introduce support right now? @ethanhs seems to be making progress, not sure if it's stable.

@ethanhs
Copy link
Contributor

@ethanhs ethanhs commented Apr 23, 2018

I am working on it. It is not stable yet. I need to finish adding type comment parsing and feature levels and port it to all the supported Python versions (3.4-3.7) and platforms (Linux, macOS, Windows). It is going to miss mypy 0.600, but I expect it will make it into 0.610.

@ddfisher
Copy link
Collaborator

@ddfisher ddfisher commented Apr 24, 2018

In general, my preference is to backport new syntax prior to full release (if support pre-release is desired), and then to do a rewrite "from scratch" on top of the new Python AST code after the official Python release has happened. That said, I think it's rare for the AST module to change much when Python is in beta, so I don't feel too strongly about this.

@ethanhs which approach are you taking now? (And have you seen the update doc? It has some useful info.)

@ethanhs
Copy link
Contributor

@ethanhs ethanhs commented Apr 24, 2018

@ddfisher I've started a full from scratch update following your guidelines (also the guide is super useful, thanks for that!). You can see my progress here: https://github.com/ethanhs/typed_ast/tree/3.7.

But since there are still 2 months till 3.7 final, you might be right that sticking to backporting makes sense in the short term. Once RC1 is released, no source changes should be made to CPython so that would be a good point to start the from scratch version.

One change that I think would be quite simple to backport is my change here: https://github.com/python/cpython/pull/6460/files#diff-4d35cf8992b795c5e97e9c8b6167cb34 which will fix #50 (it is actually really simple thankfully!).

@JelleZijlstra
Copy link

@JelleZijlstra JelleZijlstra commented May 16, 2018

One issue here for typeshed is that 3.7 makes async and await into full keywords, but typeshed's stubs for asyncio (at https://github.com/python/typeshed/blob/master/stdlib/3.4/asyncio/tasks.pyi#L26) use async as an identifier, because asyncio.async used to be an alias for asyncio.ensure_future. This means that parsing typeshed with the 3.7 AST will fail without some sort of workaround.

@gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented May 17, 2018

@gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented May 23, 2018

Note that Astroid (the parsing library used by PyLint and other tools) has switched to typed_ast: PyCQA/astroid#317 (comment). This does mean we have a responsibility to keep the API stable and we should probably test with Astroid somehow too.

@bharel
Copy link

@bharel bharel commented Jun 29, 2018

3.7.0 is now stable. @ethanhs, how's your branch doing? 😃

@ethanhs
Copy link
Contributor

@ethanhs ethanhs commented Jun 30, 2018

@bharel I am going to work on that today actually. I will probably start from scratch again since I want things to be clean, but hopefully I will be able to make some good progress based on previous work. I've started writing cross platform Python scripts to automate much of it.

@ddfisher
Copy link
Collaborator

@ddfisher ddfisher commented Jun 30, 2018

Thanks for working on that, @ethanhs!

We need to decide if we want to support async and await as non-keyword identifiers for people trying to parse Python 3.6 and below (and, if so, how). My inclination is that we need this support, especially because astroid now depends on us.

As for how we might go about doing this, I see two options:

  1. Keep the current ast3 parsing code and use it to parse Python 3.6 and below (when requested by the feature_version argument to parse.) This means the structure of the AST returned by parse could eventually differ by feature_version, which is not great.
  2. Undo the changes in python/cpython#1669 in typed_ast's parser to bring back the Python 3.6 behavior and add an explicit check to disallow the use of async and await as identifiers in Python 3.7 and above.

I think option 2 is the clear winner here.

@ethanhs
Copy link
Contributor

@ethanhs ethanhs commented Jul 1, 2018

Yes, it seems to me 2 is the best option. Since the only change to the Grammar is making async/await keywords, and the ASDLs are identitcal, perhaps we should just "backport" the 3.7 changes onto the current branch? (Save python/cpython#1669).

Also ccing @PCManticore from asteriod who might be interested in this.

@graingert
Copy link

@graingert graingert commented Aug 20, 2018

Also the new Python 3.7 AST does constant folding, will this be in typed-ast?

@edwardcwang
Copy link

@edwardcwang edwardcwang commented Oct 4, 2018

Would fixing this address python/mypy#5431?

@Mattwmaster58
Copy link
Author

@Mattwmaster58 Mattwmaster58 commented Oct 4, 2018

@edwardcwang From that same thread:

This is probably an issue with typed-ast rather than mypy.

and

The error is reported by typed_ast and it should be reported there.

@edwardcwang
Copy link

@edwardcwang edwardcwang commented Oct 4, 2018

Thanks for the pointer. Sorry for being unclear - I was unsure whether or not filing a new issue would be creating a duplicate of this issue.

MarcusCalhoun-Lopez added a commit to macports/macports-ports that referenced this issue Oct 27, 2018
MarcusCalhoun-Lopez referenced this issue in macports/macports-ports Oct 27, 2018
@bsandrow
Copy link

@bsandrow bsandrow commented Nov 19, 2018

Is this still being worked on? Just curious as the last comment from someone actually working on it is all the way back in June. Thanks in advance for all of the hard work. ^‿^

@gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Nov 20, 2018

@JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Nov 20, 2018

The Dropbox mypy team should be able to work on this in early 2019.

@gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Nov 26, 2018

See also this discussion: https://discuss.python.org/t/merge-typed-ast-back-into-cpython/377/25

Looks like we may be able to merge typed_ast back into CPython (it would seem to reduce future maintenance, though it doesn't reduce the work for the current port to 3.7 or 3.8).

The-Compiler added a commit to qutebrowser/qutebrowser that referenced this issue Nov 27, 2018
Apparently marking modules as used based on type comments doesn't work with
Python 3.7:

PyCQA/pylint#2345
python/typed_ast#60
@gvanrossum gvanrossum self-assigned this Jan 15, 2019
@gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Jan 15, 2019

This is urgent now. I am planning to attempt supporting 3.7 using the steps outlined in update_process.py. I am starting from scratch just so I get a feel for the whole process. Once I have this done I will work on incorporating as many features as possible into the CPython master (which is slated for 3.8).

@ethanhs, do you have any advice on how to do the 3.7 version?

@ethanhs
Copy link
Contributor

@ethanhs ethanhs commented Jan 15, 2019

@gvanrossum there are a few bumps along the way I ran into, but nothing major. It seems some items were moved to internal headers, so I had to copy those out. Also the update scripts only work on Mac, so I was in the process of re-writing them in Python, but that shouldn't be an issue for you. I agree we should probably undo the changes in python/cpython#1669 and make them conditionally keywords, but I didn't get that far when I was working on this.

Also, I'm happy to make sure things run well on Windows.

Also, do you want to support Python 3.4 with this newer typed_ast? I previously had to make some changes to get the compiler used for Python 3.4 to play nice. Since 3.4 is EOL'ing in 2 months I thought I'd ask.

@gvanrossum
Copy link
Member

@gvanrossum gvanrossum commented Jan 15, 2019

Agreed that the update scripts are pretty one-off, but I'm not sure they're worth it spending time on. I am now on step 4.5 in update_process.md. Agreed on the async/await keywords, or at least that some kind of hack is needed. I'd be happy to drop support for 3.4 (especially if it will be possible for mypy to use either the old or the new typed_ast, but I don't know if I can pull that off).

@msullivan
Copy link
Collaborator

@msullivan msullivan commented Jan 23, 2019

Fixed by #78

@msullivan msullivan closed this Jan 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.