Hello community, here is the log from the commit of package python-gast for openSUSE:Factory checked in at 2020-04-07 10:30:40 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-gast (Old) and /work/SRC/openSUSE:Factory/.python-gast.new.3248 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-gast" Tue Apr 7 10:30:40 2020 rev:3 rq:791744 version:0.3.3 Changes: -------- --- /work/SRC/openSUSE:Factory/python-gast/python-gast.changes 2019-09-11 10:40:05.643223252 +0200 +++ /work/SRC/openSUSE:Factory/.python-gast.new.3248/python-gast.changes 2020-04-07 10:32:05.210558420 +0200 @@ -1,0 +2,9 @@ +Mon Apr 6 11:15:56 UTC 2020 - Marketa Calabkova <mcalabk...@suse.com> + +- Update to 0.3.3 + * Fix conversion of complex literals + * Fix Ellipsis support + * Fix conversion of arguments nodes in Python 3.8 + * Use an immutable instead of a dict to store initial table + +------------------------------------------------------------------- Old: ---- gast-0.3.0.tar.gz New: ---- gast-0.3.3.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-gast.spec ++++++ --- /var/tmp/diff_new_pack.dYHnUJ/_old 2020-04-07 10:32:07.942561979 +0200 +++ /var/tmp/diff_new_pack.dYHnUJ/_new 2020-04-07 10:32:07.942561979 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-gast # -# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2020 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %define srcname gast %{?!python_module:%define python_module() python-%{**} python3-%{**}} Name: python-gast -Version: 0.3.0 +Version: 0.3.3 Release: 0 Summary: Python AST that abstracts the underlying Python version License: BSD-3-Clause ++++++ gast-0.3.0.tar.gz -> gast-0.3.3.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gast-0.3.0/.travis.yml new/gast-0.3.3/.travis.yml --- old/gast-0.3.0/.travis.yml 2019-09-07 17:43:56.000000000 +0200 +++ new/gast-0.3.3/.travis.yml 2020-01-19 21:10:35.000000000 +0100 @@ -7,6 +7,6 @@ - "3.5" - "3.6" - "3.7" - - "3.8-dev" + - "3.8" install: pip install tox-travis script: tox diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gast-0.3.0/README.rst new/gast-0.3.3/README.rst --- old/gast-0.3.0/README.rst 2019-09-07 17:43:56.000000000 +0200 +++ new/gast-0.3.3/README.rst 2020-01-19 21:10:35.000000000 +0100 @@ -47,6 +47,7 @@ - 3.5 - 3.6 - 3.7 +- 3.8 AST Changes @@ -60,14 +61,14 @@ notable exception of ``ast.arg`` being replaced by an ``ast.Name`` with an ``ast.Param`` context. -For minor version before 3.8, please note that ``Num``, ``Str``, ``Bytes`` and -``NamedConstant`` are represented as ``Constant``. +For minor version before 3.8, please note that ``Ellipsis``, ``Num``, ``Str``, +``Bytes`` and ``NamedConstant`` are represented as ``Constant``. Python2 ******* To cope with Python3 features, several nodes from the Python2 AST are extended -with some new attributes/children. +with some new attributes/children, or represented by different nodes - ``ModuleDef`` nodes have a ``type_ignores`` attribute. @@ -96,7 +97,11 @@ - ``comprehension`` nodes have an ``async`` attribute (that is always set to 0). -- ``Num`` and ``Str`` nodes are represented as ``Constant``. +- ``Ellipsis``, ``Num`` and ``Str`` nodes are represented as ``Constant``. + +- ``Subscript`` which don't have any ``Slice`` node as ``slice`` attribute (and + ``Ellipsis`` are not ``Slice`` nodes) no longer hold an ``ExtSlice`` but an + ``Index(Tuple(...))`` instead. Pit Falls diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gast-0.3.0/gast/ast2.py new/gast-0.3.3/gast/ast2.py --- old/gast-0.3.0/gast/ast2.py 2019-09-07 17:43:56.000000000 +0200 +++ new/gast-0.3.3/gast/ast2.py 2020-01-19 21:10:35.000000000 +0100 @@ -140,6 +140,44 @@ new_node.end_lineno = new_node.end_col_offset = None return new_node + def visit_Subscript(self, node): + new_slice = self._visit(node.slice) + if isinstance(node.slice, ast.Ellipsis): + new_slice = gast.Index(new_slice) + + new_node = gast.Subscript( + self._visit(node.value), + new_slice, + self._visit(node.ctx), + ) + gast.copy_location(new_node, node) + new_node.end_lineno = new_node.end_col_offset = None + return new_node + + def visit_Ellipsis(self, node): + new_node = gast.Constant( + Ellipsis, + None, + ) + gast.copy_location(new_node, node) + new_node.end_lineno = new_node.end_col_offset = None + return new_node + + def visit_ExtSlice(self, node): + has_ellipsis = any(isinstance(d, ast.Ellipsis) for d in node.dims) + has_slice = any(isinstance(d, ast.Slice) for d in node.dims) + new_dims = self._visit(node.dims) + if has_ellipsis and not has_slice: + new_dims = [nd.value if isinstance(nd, gast.Index) else nd + for nd in new_dims] + new_node = gast.Index(gast.Tuple(new_dims, + gast.Load())) + else: + new_node = gast.ExtSlice(new_dims) + gast.copy_location(new_node, node) + new_node.end_lineno = new_node.end_col_offset = None + return new_node + def visit_Str(self, node): new_node = gast.Constant( node.s, @@ -307,13 +345,32 @@ return new_node def visit_Constant(self, node): - if isinstance(node.value, (bool, int, long, float)): + if isinstance(node.value, (bool, int, long, float, complex)): new_node = ast.Num(node.value) + elif node.value is Ellipsis: + new_node = ast.Ellipsis() else: new_node = ast.Str(node.value) ast.copy_location(new_node, node) return new_node + def visit_Index(self, node): + new_value = self._visit(node.value) + if isinstance(new_value, ast.Ellipsis): + new_node = new_value + elif isinstance(new_value, ast.Tuple): + if any(isinstance(elt, ast.Ellipsis) for elt in new_value.elts): + new_elts = [elt if isinstance(elt, (ast.Ellipsis, ast.Slice)) + else ast.Index(elt) + for elt in new_value.elts] + new_node = ast.ExtSlice(new_elts) + else: + new_node = ast.Index(new_value) + else: + new_node = ast.Index(new_value) + ast.copy_location(new_node, node) + return new_node + def visit_Call(self, node): if node.args and isinstance(node.args[-1], gast.Starred): args = node.args[:-1] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gast-0.3.0/gast/ast3.py new/gast-0.3.3/gast/ast3.py --- old/gast-0.3.0/gast/ast3.py 2019-09-07 17:43:56.000000000 +0200 +++ new/gast-0.3.3/gast/ast3.py 2020-01-19 21:10:35.000000000 +0100 @@ -22,6 +22,15 @@ gast.copy_location(new_node, node) return new_node + def visit_Ellipsis(self, node): + new_node = gast.Constant( + Ellipsis, + None, + ) + gast.copy_location(new_node, node) + new_node.end_lineno = new_node.end_col_offset = None + return new_node + def visit_Str(self, node): new_node = gast.Constant( node.s, @@ -209,9 +218,11 @@ def visit_Constant(self, node): if node.value is None: new_node = ast.NameConstant(node.value) + elif node.value is Ellipsis: + new_node = ast.Ellipsis() elif isinstance(node.value, bool): new_node = ast.NameConstant(node.value) - elif isinstance(node.value, (int, float)): + elif isinstance(node.value, (int, float, complex)): new_node = ast.Num(node.value) elif isinstance(node.value, str): new_node = ast.Str(node.value) @@ -371,12 +382,16 @@ self._make_arg(node.kwarg), self._visit(node.defaults), ] if sys.version_info.minor >= 8: - extra_args.insert(0, [self._make_arg(arg) for arg in - node.posonlyargs]) - new_node = ast.arguments( - [self._make_arg(n) for n in node.args], - *extra_args - ) + new_node = ast.arguments( + [self._make_arg(arg) for arg in node.posonlyargs], + [self._make_arg(n) for n in node.args], + *extra_args + ) + else: + new_node = ast.arguments( + [self._make_arg(n) for n in node.args], + *extra_args + ) return new_node diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gast-0.3.0/gast/gast.py new/gast-0.3.3/gast/gast.py --- old/gast-0.3.0/gast/gast.py 2019-09-07 17:43:56.000000000 +0200 +++ new/gast-0.3.3/gast/gast.py 2020-01-19 21:10:35.000000000 +0100 @@ -33,256 +33,259 @@ {'__init__': create_node})) -_nodes = { +_nodes = ( # mod - 'Module': (('body', 'type_ignores'), (), (mod,)), - 'Interactive': (('body',), (), (mod,)), - 'Expression': (('body',), (), (mod,)), - 'FunctionType': (('argtypes', 'returns'), (), (mod,)), - 'Suite': (('body',), (), (mod,)), + ('Module', (('body', 'type_ignores'), (), (mod,))), + ('Interactive', (('body',), (), (mod,))), + ('Expression', (('body',), (), (mod,))), + ('FunctionType', (('argtypes', 'returns'), (), (mod,))), + ('Suite', (('body',), (), (mod,))), # stmt - 'FunctionDef': (('name', 'args', 'body', 'decorator_list', 'returns', - 'type_comment'), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'AsyncFunctionDef': (('name', 'args', 'body', - 'decorator_list', 'returns', - 'type_comment'), - ('lineno', 'col_offset', - 'end_lineno', 'end_col_offset',), - (stmt,)), - 'ClassDef': (('name', 'bases', 'keywords', 'body', 'decorator_list',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'Return': (('value',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'Delete': (('targets',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'Assign': (('targets', 'value',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'AugAssign': (('target', 'op', 'value',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'AnnAssign': (('target', 'annotation', 'value', 'simple',), + ('FunctionDef', (('name', 'args', 'body', 'decorator_list', 'returns', + 'type_comment'), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('AsyncFunctionDef', (('name', 'args', 'body', + 'decorator_list', 'returns', + 'type_comment'), + ('lineno', 'col_offset', + 'end_lineno', 'end_col_offset',), + (stmt,))), + ('ClassDef', (('name', 'bases', 'keywords', 'body', 'decorator_list',), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'Print': (('dest', 'values', 'nl',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'For': (('target', 'iter', 'body', 'orelse', 'type_comment'), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'AsyncFor': (('target', 'iter', 'body', 'orelse', 'type_comment'), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'While': (('test', 'body', 'orelse',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'If': (('test', 'body', 'orelse',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'With': (('items', 'body', 'type_comment'), + (stmt,))), + ('Return', (('value',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('Delete', (('targets',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('Assign', (('targets', 'value',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('AugAssign', (('target', 'op', 'value',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('AnnAssign', (('target', 'annotation', 'value', 'simple',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('Print', (('dest', 'values', 'nl',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('For', (('target', 'iter', 'body', 'orelse', 'type_comment'), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'AsyncWith': (('items', 'body', 'type_comment'), + (stmt,))), + ('AsyncFor', (('target', 'iter', 'body', 'orelse', 'type_comment'), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'Raise': (('exc', 'cause',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'Try': (('body', 'handlers', 'orelse', 'finalbody',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'Assert': (('test', 'msg',), + (stmt,))), + ('While', (('test', 'body', 'orelse',), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'Import': (('names',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'ImportFrom': (('module', 'names', 'level',), + (stmt,))), + ('If', (('test', 'body', 'orelse',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('With', (('items', 'body', 'type_comment'), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('AsyncWith', (('items', 'body', 'type_comment'), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'Exec': (('body', 'globals', 'locals',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'Global': (('names',), + (stmt,))), + ('Raise', (('exc', 'cause',), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'Nonlocal': (('names',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'Expr': (('value',), + (stmt,))), + ('Try', (('body', 'handlers', 'orelse', 'finalbody',), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'Pass': ((), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'Break': ((), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), - 'Continue': ((), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (stmt,)), + (stmt,))), + ('Assert', (('test', 'msg',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('Import', (('names',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('ImportFrom', (('module', 'names', 'level',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('Exec', (('body', 'globals', 'locals',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('Global', (('names',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('Nonlocal', (('names',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('Expr', (('value',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('Pass', ((), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('Break', ((), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), + ('Continue', ((), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (stmt,))), # expr - 'BoolOp': (('op', 'values',), + ('BoolOp', (('op', 'values',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (expr,))), + ('BinOp', (('left', 'op', 'right',), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'BinOp': (('left', 'op', 'right',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'UnaryOp': (('op', 'operand',), + (expr,))), + ('UnaryOp', (('op', 'operand',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (expr,))), + ('Lambda', (('args', 'body',), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'Lambda': (('args', 'body',), + (expr,))), + ('IfExp', (('test', 'body', 'orelse',), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'IfExp': (('test', 'body', 'orelse',), + (expr,))), + ('Dict', (('keys', 'values',), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'Dict': (('keys', 'values',), + (expr,))), + ('Set', (('elts',), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'Set': (('elts',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'ListComp': (('elt', 'generators',), + (expr,))), + ('ListComp', (('elt', 'generators',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (expr,))), + ('SetComp', (('elt', 'generators',), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'SetComp': (('elt', 'generators',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'DictComp': (('key', 'value', 'generators',), + (expr,))), + ('DictComp', (('key', 'value', 'generators',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (expr,))), + ('GeneratorExp', (('elt', 'generators',), + ('lineno', 'col_offset', + 'end_lineno', 'end_col_offset',), + (expr,))), + ('Await', (('value',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (expr,))), + ('Yield', (('value',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (expr,))), + ('YieldFrom', (('value',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (expr,))), + ('Compare', (('left', 'ops', 'comparators',), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'GeneratorExp': (('elt', 'generators',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'Await': (('value',), + (expr,))), + ('Call', (('func', 'args', 'keywords',), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'Yield': (('value',), + (expr,))), + ('Repr', (('value',), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'YieldFrom': (('value',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'Compare': (('left', 'ops', 'comparators',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'Call': (('func', 'args', 'keywords',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'Repr': (('value',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'FormattedValue': (('value', 'conversion', 'format_spec',), - ('lineno', 'col_offset', - 'end_lineno', 'end_col_offset',), - (expr,)), - 'JoinedStr': (('values',), + (expr,))), + ('FormattedValue', (('value', 'conversion', 'format_spec',), + ('lineno', 'col_offset', + 'end_lineno', 'end_col_offset',), + (expr,))), + ('JoinedStr', (('values',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (expr,))), + ('Constant', (('value', 'kind'), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'Constant': (('value', 'kind'), + (expr,))), + ('Attribute', (('value', 'attr', 'ctx',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (expr,))), + ('Subscript', (('value', 'slice', 'ctx',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (expr,))), + ('Starred', (('value', 'ctx',), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'Attribute': (('value', 'attr', 'ctx',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'Subscript': (('value', 'slice', 'ctx',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'Starred': (('value', 'ctx',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'Name': (('id', 'ctx', 'annotation', 'type_comment'), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'List': (('elts', 'ctx',), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), - 'Tuple': (('elts', 'ctx',), + (expr,))), + ('Name', (('id', 'ctx', 'annotation', 'type_comment'), ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), - (expr,)), + (expr,))), + ('List', (('elts', 'ctx',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (expr,))), + ('Tuple', (('elts', 'ctx',), + ('lineno', 'col_offset', 'end_lineno', 'end_col_offset',), + (expr,))), # expr_context - 'Load': ((), (), (expr_context,)), - 'Store': ((), (), (expr_context,)), - 'Del': ((), (), (expr_context,)), - 'AugLoad': ((), (), (expr_context,)), - 'AugStore': ((), (), (expr_context,)), - 'Param': ((), (), (expr_context,)), + ('Load', ((), (), (expr_context,))), + ('Store', ((), (), (expr_context,))), + ('Del', ((), (), (expr_context,))), + ('AugLoad', ((), (), (expr_context,))), + ('AugStore', ((), (), (expr_context,))), + ('Param', ((), (), (expr_context,))), # slice - 'Slice': (('lower', 'upper', 'step'), (), (slice,)), - 'ExtSlice': (('dims',), (), (slice,)), - 'Index': (('value',), (), (slice,)), + ('Slice', (('lower', 'upper', 'step'), (), (slice,))), + ('ExtSlice', (('dims',), (), (slice,))), + ('Index', (('value',), (), (slice,))), # boolop - 'And': ((), (), (boolop,)), - 'Or': ((), (), (boolop,)), + ('And', ((), (), (boolop,))), + ('Or', ((), (), (boolop,))), # operator - 'Add': ((), (), (operator,)), - 'Sub': ((), (), (operator,)), - 'Mult': ((), (), (operator,)), - 'MatMult': ((), (), (operator,)), - 'Div': ((), (), (operator,)), - 'Mod': ((), (), (operator,)), - 'Pow': ((), (), (operator,)), - 'LShift': ((), (), (operator,)), - 'RShift': ((), (), (operator,)), - 'BitOr': ((), (), (operator,)), - 'BitXor': ((), (), (operator,)), - 'BitAnd': ((), (), (operator,)), - 'FloorDiv': ((), (), (operator,)), + ('Add', ((), (), (operator,))), + ('Sub', ((), (), (operator,))), + ('Mult', ((), (), (operator,))), + ('MatMult', ((), (), (operator,))), + ('Div', ((), (), (operator,))), + ('Mod', ((), (), (operator,))), + ('Pow', ((), (), (operator,))), + ('LShift', ((), (), (operator,))), + ('RShift', ((), (), (operator,))), + ('BitOr', ((), (), (operator,))), + ('BitXor', ((), (), (operator,))), + ('BitAnd', ((), (), (operator,))), + ('FloorDiv', ((), (), (operator,))), # unaryop - 'Invert': ((), (), (unaryop, AST,)), - 'Not': ((), (), (unaryop, AST,)), - 'UAdd': ((), (), (unaryop, AST,)), - 'USub': ((), (), (unaryop, AST,)), + ('Invert', ((), (), (unaryop, AST,))), + ('Not', ((), (), (unaryop, AST,))), + ('UAdd', ((), (), (unaryop, AST,))), + ('USub', ((), (), (unaryop, AST,))), # cmpop - 'Eq': ((), (), (cmpop,)), - 'NotEq': ((), (), (cmpop,)), - 'Lt': ((), (), (cmpop,)), - 'LtE': ((), (), (cmpop,)), - 'Gt': ((), (), (cmpop,)), - 'GtE': ((), (), (cmpop,)), - 'Is': ((), (), (cmpop,)), - 'IsNot': ((), (), (cmpop,)), - 'In': ((), (), (cmpop,)), - 'NotIn': ((), (), (cmpop,)), + ('Eq', ((), (), (cmpop,))), + ('NotEq', ((), (), (cmpop,))), + ('Lt', ((), (), (cmpop,))), + ('LtE', ((), (), (cmpop,))), + ('Gt', ((), (), (cmpop,))), + ('GtE', ((), (), (cmpop,))), + ('Is', ((), (), (cmpop,))), + ('IsNot', ((), (), (cmpop,))), + ('In', ((), (), (cmpop,))), + ('NotIn', ((), (), (cmpop,))), # comprehension - 'comprehension': (('target', 'iter', 'ifs', 'is_async'), (), (AST,)), + ('comprehension', (('target', 'iter', 'ifs', 'is_async'), (), (AST,))), # excepthandler - 'ExceptHandler': (('type', 'name', 'body'), - ('lineno', 'col_offset', 'end_lineno', 'end_col_offset'), - (excepthandler,)), + ('ExceptHandler', (('type', 'name', 'body'), + ('lineno', 'col_offset', + 'end_lineno', 'end_col_offset'), + (excepthandler,))), # arguments - 'arguments': (('args', 'posonlyargs', 'vararg', 'kwonlyargs', - 'kw_defaults', 'kwarg', 'defaults'), (), (AST,)), + ('arguments', (('args', 'posonlyargs', 'vararg', 'kwonlyargs', + 'kw_defaults', 'kwarg', 'defaults'), (), (AST,))), # keyword - 'keyword': (('arg', 'value'), (), (AST,)), + ('keyword', (('arg', 'value'), (), (AST,))), # alias - 'alias': (('name', 'asname'), (), (AST,)), + ('alias', (('name', 'asname'), (), (AST,))), # withitem - 'withitem': (('context_expr', 'optional_vars'), (), (AST,)), + ('withitem', (('context_expr', 'optional_vars'), (), (AST,))), # type_ignore - 'type_ignore': ((), ('lineno', 'tag'), (TypeIgnore,)), -} + ('type_ignore', ((), ('lineno', 'tag'), (TypeIgnore,))), + ) -for name, descr in _nodes.items(): +for name, descr in _nodes: _make_node(name, *descr) if _sys.version_info.major == 2: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gast-0.3.0/setup.py new/gast-0.3.3/setup.py --- old/gast-0.3.0/setup.py 2019-09-07 17:43:56.000000000 +0200 +++ new/gast-0.3.3/setup.py 2020-01-19 21:10:35.000000000 +0100 @@ -10,7 +10,7 @@ kw = {} setup(name='gast', # gast, daou naer! - version='0.3.0', + version='0.3.3', packages=['gast'], description='Python AST that abstracts the underlying Python version', long_description=''' diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/gast-0.3.0/tests/test_compat.py new/gast-0.3.3/tests/test_compat.py --- old/gast-0.3.0/tests/test_compat.py 2019-09-07 17:43:56.000000000 +0200 +++ new/gast-0.3.3/tests/test_compat.py 2020-01-19 21:10:35.000000000 +0100 @@ -96,6 +96,20 @@ "[TypeIgnore(lineno=1, tag='[excuse]')])") self.assertEqual(gast.dump(tree), norm) + def test_PosonlyArgs(self): + code = 'def foo(a, /, b): pass' + tree = gast.parse(code, type_comments=True) + compile(gast.gast_to_ast(tree), '<test>', 'exec') + norm = ("Module(body=[FunctionDef(name='foo', args=arguments(" + "args=[Name(id='b', ctx=Param(), annotation=None, " + "type_comment=None)], posonlyargs=[Name(id='a', " + "ctx=Param(), annotation=None, type_comment=None)], " + "vararg=None, kwonlyargs=[], kw_defaults=[], " + "kwarg=None, defaults=[]), body=[Pass()], " + "decorator_list=[], returns=None, type_comment=None)" + "], type_ignores=[])") + self.assertEqual(gast.dump(tree), norm) + else: def test_Bytes(self): @@ -229,6 +243,81 @@ "type_ignores=[])") self.assertEqual(gast.dump(tree), norm) + def test_Index(self): + code = 'def foo(a): a[1]' + tree = gast.parse(code) + compile(gast.gast_to_ast(tree), '<test>', 'exec') + norm = ("Module(body=[FunctionDef(name='foo', args=arguments(args=[" + "Name(id='a', ctx=Param(), annotation=None, type_comment=None)" + "], posonlyargs=[], vararg=None, kwonlyargs=[], kw_defaults=[]" + ", kwarg=None, defaults=[]), body=[Expr(value=Subscript(value=" + "Name(id='a', ctx=Load(), annotation=None, type_comment=None)" + ", slice=Index(value=Constant(value=1, kind=None)), ctx=Load()" + "))], decorator_list=[], returns=None, type_comment=None)]" + ", type_ignores=[])") + self.assertEqual(gast.dump(tree), norm) + + def test_ExtSlice(self): + code = 'def foo(a): a[:,:]' + tree = gast.parse(code) + compile(gast.gast_to_ast(tree), '<test>', 'exec') + norm = ("Module(body=[FunctionDef(name='foo', args=arguments(args=[" + "Name(id='a', ctx=Param(), annotation=None, type_comment=None)" + "], posonlyargs=[], vararg=None, kwonlyargs=[], kw_defaults=[]" + ", kwarg=None, defaults=[]), body=[Expr(value=Subscript(value=" + "Name(id='a', ctx=Load(), annotation=None, type_comment=None)" + ", slice=ExtSlice(dims=[Slice(lower=None, upper=None, step=" + "None), Slice(lower=None, upper=None, step=None)]), ctx=Load()" + "))], decorator_list=[], returns=None, type_comment=None)], " + "type_ignores=[])") + self.assertEqual(gast.dump(tree), norm) + + def test_ExtSlices(self): + code = 'def foo(a): a[1,:]' + tree = gast.parse(code) + compile(gast.gast_to_ast(tree), '<test>', 'exec') + norm = ("Module(body=[FunctionDef(name='foo', args=arguments(args=[" + "Name(id='a', ctx=Param(), annotation=None, type_comment=None)" + "], posonlyargs=[], vararg=None, kwonlyargs=[], kw_defaults=[]" + ", kwarg=None, defaults=[]), body=[Expr(value=Subscript(value=" + "Name(id='a', ctx=Load(), annotation=None, type_comment=None)" + ", slice=ExtSlice(dims=[Index(value=Constant(value=1, kind=" + "None)), Slice(lower=None, upper=None, step=None)]), ctx=Load" + "()))], decorator_list=[], returns=None, type_comment=None)]" + ", type_ignores=[])") + self.assertEqual(gast.dump(tree), norm) + + def test_Ellipsis(self): + self.maxDiff = None + code = 'def foo(a): a[...]' + tree = gast.parse(code) + compile(gast.gast_to_ast(tree), '<test>', 'exec') + norm = ("Module(body=[FunctionDef(name='foo', args=arguments(args=[" + "Name(id='a', ctx=Param(), annotation=None, type_comment=None)" + "], posonlyargs=[], vararg=None, kwonlyargs=[], kw_defaults=[]" + ", kwarg=None, defaults=[]), body=[Expr(value=Subscript(value=" + "Name(id='a', ctx=Load(), annotation=None, type_comment=None)" + ", slice=Index(value=Constant(value=Ellipsis, kind=None)), ctx" + "=Load()))], decorator_list=[], returns=None, type_comment=" + "None)], type_ignores=[])") + self.assertEqual(gast.dump(tree), norm) + + def test_ExtSliceEllipsis(self): + self.maxDiff = None + code = 'def foo(a): a[1, ...]' + tree = gast.parse(code) + compile(gast.gast_to_ast(tree), '<test>', 'exec') + norm = ("Module(body=[FunctionDef(name='foo', args=arguments(args=[" + "Name(id='a', ctx=Param(), annotation=None, type_comment=None)" + "], posonlyargs=[], vararg=None, kwonlyargs=[], kw_defaults=[]" + ", kwarg=None, defaults=[]), body=[Expr(value=Subscript(value=" + "Name(id='a', ctx=Load(), annotation=None, type_comment=None)" + ", slice=Index(value=Tuple(elts=[Constant(value=1, kind=None)" + ", Constant(value=Ellipsis, kind=None)], ctx=Load())), ctx=" + "Load()))], decorator_list=[], returns=None, type_comment=" + "None)], type_ignores=[])") + self.assertEqual(gast.dump(tree), norm) + if __name__ == '__main__': unittest.main()