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

Python 3.8 support and existing test status #17

Closed
EvanKepner opened this issue Nov 3, 2019 · 3 comments
Closed

Python 3.8 support and existing test status #17

EvanKepner opened this issue Nov 3, 2019 · 3 comments
Labels
enhancement New feature or request maintenance

Comments

@EvanKepner
Copy link
Owner

There are failing tests in the CICD setting using Python 3.8, update to address these issues and determine if it's a functionality problem or a test bias. Besides the coverage reader in filters, mutatest is built entirely on the standard library so it may be a test problem.

@EvanKepner
Copy link
Owner Author

New AST functions in 3.8: https://docs.python.org/3/whatsnew/3.8.html#improved-modules

import ast
import sys

EXAMPLE = """
def add_ten(b):
    return b + 11 - 1
"""

print("VERSION:", sys.version)

parsed_tree = ast.parse(EXAMPLE)

print("RETURN OPTION:")
print(parsed_tree.body[0].body[0].value.__dict__)

print("LEFT")
print(parsed_tree.body[0].body[0].value.left.__dict__)

print("RIGHT")
print(parsed_tree.body[0].body[0].value.right.__dict__)

In 3.8:

RETURN OPTION:
{'left': <_ast.BinOp object at 0x7f5ca43aa3a0>, 'op': <_ast.Sub object at 0x7f5ca43c4b20>, 'right': <_ast.Constant object at 0x7f5ca43aa3d0>, 'lineno': 3, 'col_offset': 11, 'end_lineno': 3, 'end_col_offset': 21}
LEFT
{'left': <_ast.Name object at 0x7f5ca43aa370>, 'op': <_ast.Add object at 0x7f5ca43c4ac0>, 'right': <_ast.Constant object at 0x7f5ca43aaa30>, 'lineno': 3, 'col_offset': 11, 'end_lineno': 3, 'end_col_offset': 17}
RIGHT
{'value': 1, 'kind': None, 'lineno': 3, 'col_offset': 20, 'end_lineno': 3, 'end_col_offset': 21}

In 3.7:

RETURN OPTION:
{'left': <_ast.BinOp object at 0x7f062a4fec50>, 'op': <_ast.Sub object at 0x7f062a4f3668>, 'right': <_ast.Num object at 0x7f062a4fed30>, 'lineno': 3, 'col_offset': 18}
LEFT
{'left': <_ast.Name object at 0x7f062a4fec88>, 'op': <_ast.Add object at 0x7f062a4f35c0>, 'right': <_ast.Num object at 0x7f062a4fecf8>, 'lineno': 3, 'col_offset': 11}
RIGHT
{'n': 1, 'lineno': 3, 'col_offset': 20}

In 3.8, the end_col_offset column is new and combined with the col_offset defines the location for updating the nodes. In 3.7, only col_offset is used. This will require an update to transformers to use the new location parameters, and likely LocIndex values. TBD whether or not it is worth supporting Py37 after implementing this Py38 AST change.

@EvanKepner EvanKepner added the enhancement New feature or request label Nov 10, 2019
@EvanKepner
Copy link
Owner Author

Seems like supporting both 3.7 and 3.8 will be possible: 1a5c0bd

More WIP on ensuring 3.8 functions are supported, but this will pass 3.7 tests and support basic operations on supported node types.

@EvanKepner
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request maintenance
Projects
None yet
Development

No branches or pull requests

1 participant