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

Create python3.8 parser #3384

Merged
merged 3 commits into from Jan 30, 2020
Merged

Create python3.8 parser #3384

merged 3 commits into from Jan 30, 2020

Conversation

gforsyth
Copy link
Collaborator

@gforsyth gforsyth commented Nov 7, 2019

This builds on earlier work by @carmenbianca -- I've moved the 3.8+
specific parser code (involving the posonlyargs) to a python 3.8
parser class that inherits from the 3.6 parser.

@@ -0,0 +1,307 @@
# -*- coding: utf-8 -*-
"""Implements the xonsh parser for Python v3.6."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be for 3.8 😉

@scopatz
Copy link
Member

scopatz commented Nov 8, 2019

This is awesome! Thanks @gforsyth! Do we need any more tests here?

Also, should probably enable CI for 3.8 before merging. I belive that conda-forge has packages for everything we need for xonsh now for v3.8

@gforsyth
Copy link
Collaborator Author

Hrrrr,

so yeah, we need more tests. Also, on 3.8 current parser tests are failing. I believe this is due to a change in the AST in python 3.8 -- there are now two additional attributes for ast.stmt and ast.expr: end_lineno and end_col_offset.

little bit of info here: https://docs.python.org/3.8/library/ast.html#ast.AST.lineno

Also looks like ast.Num, ast.Str, ast.Bytes, ast.NameConstant, and ast.Ellipsis are being deprecated in favor of ast.Constant

6 tests are failing because AssertionError: Ast nodes do not have the same line number : 2 != 1

@gforsyth
Copy link
Collaborator Author

Hmm, interesting. All of the failures involve decorators:

============================================================= FAILURES =============================================================
__________________________________________________________ test_decorator __________________________________________________________

    def test_decorator():
>       check_stmts("@g\ndef f():\n  pass", False)
E       AssertionError: Ast nodes do not have the same line number : 2 != 1

tests/test_parser.py:1931: AssertionError
_________________________________________________________ test_decorator_2 _________________________________________________________

    def test_decorator_2():
>       check_stmts("@h\n@g\ndef f():\n  pass", False)
E       AssertionError: Ast nodes do not have the same line number : 3 != 1

tests/test_parser.py:1935: AssertionError
_______________________________________________________ test_decorator_call ________________________________________________________

    def test_decorator_call():
>       check_stmts("@g()\ndef f():\n  pass", False)
E       AssertionError: Ast nodes do not have the same line number : 2 != 1

tests/test_parser.py:1939: AssertionError
_____________________________________________________ test_decorator_call_args _____________________________________________________

    def test_decorator_call_args():
>       check_stmts("@g(x, y=10)\ndef f():\n  pass", False)
E       AssertionError: Ast nodes do not have the same line number : 2 != 1

tests/test_parser.py:1943: AssertionError
___________________________________________________ test_decorator_dot_call_args ___________________________________________________

    def test_decorator_dot_call_args():
>       check_stmts("@h.g(x, y=10)\ndef f():\n  pass", False)
E       AssertionError: Ast nodes do not have the same line number : 2 != 1

tests/test_parser.py:1947: AssertionError
_________________________________________________ test_decorator_dot_dot_call_args _________________________________________________

    def test_decorator_dot_dot_call_args():
>       check_stmts("@i.h.g(x, y=10)\ndef f():\n  pass", False)
E       AssertionError: Ast nodes do not have the same line number : 2 != 1

tests/test_parser.py:1951: AssertionError

gforsyth and others added 2 commits November 15, 2019 16:49
This builds on earlier work by @carmenbianca -- I've moved the 3.8+
specific parser code (involving the `posonlyargs`) to a python 3.8
parser class that inherits from the 3.6 parser.
@gforsyth
Copy link
Collaborator Author

Ok, this is ready for another look.

I think that at this stage it actually doesn't need more tests, in that all this PR is doing is making sure that xonsh can run on Python 3.8. Python 3.8 is now enabled in CI and tests are passing, so huzzah! And @scopatz, it looks like 3.8 changed a bit of the AST involving decorator position that you found a bit odd, as per this comment: https://github.com/xonsh/xonsh/blob/master/xonsh/parsers/base.py#L823-L826

There is a much bigger lift which is adding support for positional-only parameter support which landed in 3.8: https://www.python.org/dev/peps/pep-0570/#syntax-and-semantics

This is going to require a bit of extra noodling in the parser to handle all the new possible function signatures (I'm playing with this but someone else should feel free to take a crack at it, too).

@gforsyth
Copy link
Collaborator Author

Ping @xonsh/xore

@gforsyth
Copy link
Collaborator Author

Anyone in @xonsh/xore available to take a look at this?

@melund
Copy link
Member

melund commented Jan 30, 2020

Thanks for all the effort @gforsyth . I have read through the code and tried it with python3.8. I can merge this.

I still think we have problem with releasing, since #3342 may have broken other things. @scopatz is probably the one to judge this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants