diff --git a/.github/workflows/core.yml b/.github/workflows/core.yml new file mode 100644 index 0000000..1140cda --- /dev/null +++ b/.github/workflows/core.yml @@ -0,0 +1,31 @@ +name: core + +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + build: + runs-on: ubuntu-18.04 + strategy: + matrix: + python-version: [3.6, 3.8, 3.9, 3.10-dev] + steps: + - uses: actions/checkout@v2 + - name: Setup Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install astunparse pytest + - name: Setup + run: | + python setup.py install + - name: Testing sequential + run: | + pytest diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 965b1cc..0000000 --- a/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -sudo: required # for 3.7, see https://github.com/travis-ci/travis-ci/issues/9069#issuecomment-425720905 -language: python -dist: xenial -python: - - "2.7" - - "3.4" - - "3.5" - - "3.6" - - "3.7" - - "3.8" - - "3.9-dev" -jobs: - include: - - python: "3.8" - env: TOXENV=lint -install: pip install tox-travis -script: tox diff --git a/README.rst b/README.rst index 8a55a9a..d26f2d7 100644 --- a/README.rst +++ b/README.rst @@ -49,6 +49,7 @@ GAST is tested using ``tox`` and Travis on the following Python versions: - 3.7 - 3.8 - 3.9 +- 3.10 AST Changes @@ -248,6 +249,7 @@ ASDL -- import name with optional 'as' alias. alias = (identifier name, identifier? asname) + attributes (int lineno, int col_offset, int? end_lineno, int? end_col_offset) withitem = (expr context_expr, expr? optional_vars) diff --git a/gast/ast2.py b/gast/ast2.py index 8968b5b..ad2afb9 100644 --- a/gast/ast2.py +++ b/gast/ast2.py @@ -253,6 +253,15 @@ def visit_arguments(self, node): ) return new_node + def visit_alias(self, node): + new_node = gast.alias( + self._visit(node.name), + self._visit(node.asname), + ) + new_node.lineno = new_node.col_offset = None + new_node.end_lineno = new_node.end_col_offset = None + return new_node + class GAstToAst2(GAstToAst): @@ -431,6 +440,13 @@ def visit_arguments(self, node): ) return new_node + def visit_alias(self, node): + new_node = ast.alias( + self._visit(node.name), + self._visit(node.asname) + ) + return new_node + def ast_to_gast(node): return Ast2ToGAst().visit(node) diff --git a/gast/ast3.py b/gast/ast3.py index d0f0d39..a1e2436 100644 --- a/gast/ast3.py +++ b/gast/ast3.py @@ -5,6 +5,17 @@ class Ast3ToGAst(AstToGAst): + if sys.version_info.minor < 10: + + def visit_alias(self, node): + new_node = gast.alias( + self._visit(node.name), + self._visit(node.asname), + ) + new_node.lineno = new_node.col_offset = None + new_node.end_lineno = new_node.end_col_offset = None + return new_node + if sys.version_info.minor < 9: def visit_ExtSlice(self, node): @@ -230,6 +241,14 @@ def visit_comprehension(self, node): class GAstToAst3(GAstToAst): + if sys.version_info.minor < 10: + def visit_alias(self, node): + new_node = ast.alias( + self._visit(node.name), + self._visit(node.asname) + ) + return new_node + if sys.version_info.minor < 9: def visit_Subscript(self, node): def adjust_slice(s): diff --git a/gast/gast.py b/gast/gast.py index 00150ca..173b804 100644 --- a/gast/gast.py +++ b/gast/gast.py @@ -278,7 +278,9 @@ def create_node(self, *args, **kwargs): (AST,))), # alias - ('alias', (('name', 'asname'), (), (AST,))), + ('alias', (('name', 'asname'), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset'), + (AST,))), # withitem ('withitem', (('context_expr', 'optional_vars'), (), (AST,))), diff --git a/setup.py b/setup.py index f6284c6..236554f 100644 --- a/setup.py +++ b/setup.py @@ -34,6 +34,9 @@ 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', ], python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*', **kw