Skip to content

Commit

Permalink
Merge pull request #57 from serge-sans-paille/feature/python-3.10
Browse files Browse the repository at this point in the history
Testing support for python 3.10
  • Loading branch information
serge-sans-paille authored Jun 28, 2021
2 parents 1cb0f19 + 159cb50 commit eb1ea03
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 18 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/core.yml
Original file line number Diff line number Diff line change
@@ -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
17 changes: 0 additions & 17 deletions .travis.yml

This file was deleted.

2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
16 changes: 16 additions & 0 deletions gast/ast2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down Expand Up @@ -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)
Expand Down
19 changes: 19 additions & 0 deletions gast/ast3.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
4 changes: 3 additions & 1 deletion gast/gast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,))),
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eb1ea03

Please sign in to comment.