Skip to content

Commit

Permalink
Add support for python 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
soupytwist committed Nov 16, 2023
1 parent d69a86f commit 9af5611
Show file tree
Hide file tree
Showing 55 changed files with 2,029 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pasta/base/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,9 +566,15 @@ def visit_Try(self, node):
for stmt in self.indented(node, 'finalbody'):
self.visit(stmt)

# Added in python 3.11
def visit_TryStar(self, node):
return self.visit_Try(node)

@block_statement
def visit_ExceptHandler(self, node):
self.token('except')
# except* support https://peps.python.org/pep-0654/#except
self.optional_token(node, 'star', '*', allow_whitespace_prefix=True)
self.attr(node, 'leading_ws', [self.ws], default=' ')
if node.type:
self.visit(node.type)
Expand Down
43 changes: 43 additions & 0 deletions testdata/ast/golden/3.11/annassign.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
(-1, -1) Module prefix=|@@indent@@| suffix=|| indent=||
(1, 0) ClassDef A prefix=|| suffix=|| indent=||
(5, 0) ClassDef G prefix=|\n@@indent@@| suffix=|| indent=||
(8, 0) AnnAssign prefix=|\n@@indent@@| suffix=|\n| indent=||
(10, 0) AnnAssign prefix=|\n@@indent@@| suffix=|\n| indent=||
(12, 0) AnnAssign prefix=|\n@@indent@@| suffix=|\n| indent=||
(2, 2) AnnAssign prefix=|@@indent@@| suffix=|\n| indent=| |
(3, 2) AnnAssign prefix=|@@indent@@| suffix=|\n| indent=| |
(6, 2) AnnAssign prefix=|@@indent@@| suffix=|\n| indent=| |
(8, 0) Name j prefix=|| suffix=|| indent=||
(8, 3) Name K prefix=|| suffix=|| indent=||
(10, 0) Name l prefix=|| suffix=| | indent=||
(10, 7) Name M prefix=|| suffix=|| indent=||
(10, 12) Name n prefix=|| suffix=|| indent=||
(12, 0) Subscript prefix=|| suffix=|| indent=||
(12, 6) Name q prefix=|| suffix=| | indent=||
(12, 10) Name r prefix=|| suffix=|| indent=||
(2, 2) Name b prefix=|| suffix=|| indent=| |
(2, 5) Name C prefix=|| suffix=|| indent=| |
(3, 2) Name d prefix=|| suffix=|| indent=| |
(3, 5) Name E prefix=|| suffix=| | indent=| |
(3, 9) Name f prefix=|| suffix=|| indent=| |
(6, 4) Name h prefix=|( | suffix=| )| indent=| |
(6, 12) Name I prefix=|| suffix=|| indent=| |
(-1, -1) Store prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Store prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(12, 0) Name o prefix=|| suffix=|| indent=||
(12, 2) Name p prefix=|| suffix=|| indent=||
(-1, -1) Store prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Store prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Store prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Store prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
12 changes: 12 additions & 0 deletions testdata/ast/golden/3.11/assert.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
(-1, -1) Module prefix=|@@indent@@| suffix=|| indent=||
(1, 0) Assert prefix=|| suffix=|\n| indent=||
(3, 0) Assert prefix=|\n@@indent@@| suffix=|\n| indent=||
(5, 0) Assert prefix=|\n@@indent@@| suffix=|\n| indent=||
(1, 7) Name a prefix=|| suffix=|| indent=||
(3, 8) Name b prefix=|(| suffix=|)| indent=||
(5, 9) Name c prefix=|| suffix=| | indent=||
(5, 15) Name d prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
20 changes: 20 additions & 0 deletions testdata/ast/golden/3.11/assign.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(-1, -1) Module prefix=|@@indent@@| suffix=|| indent=||
(1, 0) Assign prefix=|| suffix=|\n| indent=||
(3, 0) Assign prefix=|\n@@indent@@| suffix=|\n| indent=||
(5, 0) Assign prefix=|\n@@indent@@| suffix=|\n| indent=||
(1, 0) Name a prefix=|| suffix=| | indent=||
(1, 4) Name b prefix=|| suffix=|| indent=||
(3, 0) Name c prefix=|| suffix=| | indent=||
(3, 4) Name d prefix=|| suffix=| | indent=||
(3, 9) Name e prefix=|| suffix=|| indent=||
(5, 0) Name f prefix=|| suffix=|| indent=||
(5, 2) Name g prefix=|| suffix=| | indent=||
(5, 8) Name h prefix=|| suffix=|| indent=||
(-1, -1) Store prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Store prefix=|| suffix=|| indent=||
(-1, -1) Store prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Store prefix=|| suffix=|| indent=||
(-1, -1) Store prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
23 changes: 23 additions & 0 deletions testdata/ast/golden/3.11/async.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(-1, -1) Module prefix=|@@indent@@| suffix=|@@indent@@| indent=||
(1, 0) AsyncFunctionDef a prefix=|| suffix=|| indent=||
(4, 0) AsyncWith prefix=|\n@@indent@@| suffix=|| indent=||
(7, 0) AsyncFor prefix=|\n@@indent@@| suffix=|| indent=||
(-1, -1) arguments prefix=|| suffix=|| indent=||
(2, 2) Expr prefix=|@@indent@@| suffix=|\n| indent=| |
(-1, -1) withitem prefix=|| suffix=|| indent=||
(5, 2) Expr prefix=|@@indent@@| suffix=|\n| indent=| |
(7, 10) Name f prefix=|| suffix=| | indent=||
(7, 15) Name g prefix=|| suffix=|| indent=||
(8, 2) Expr prefix=|@@indent@@| suffix=|\n| indent=| |
(1, 12) arg b prefix=|| suffix=|| indent=||
(2, 2) Name c prefix=|| suffix=|| indent=| |
(4, 11) Name d prefix=|| suffix=|| indent=||
(5, 2) Name e prefix=|| suffix=|| indent=| |
(-1, -1) Store prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(8, 2) Await prefix=|| suffix=|| indent=| |
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(8, 8) Name i prefix=|| suffix=|| indent=| |
(-1, -1) Load prefix=|| suffix=|| indent=||
16 changes: 16 additions & 0 deletions testdata/ast/golden/3.11/attribute.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(-1, -1) Module prefix=|@@indent@@| suffix=|| indent=||
(1, 0) Expr prefix=|| suffix=|\n| indent=||
(3, 0) Expr prefix=|\n@@indent@@| suffix=|\n| indent=||
(5, 0) Expr prefix=|\n@@indent@@| suffix=|\n| indent=||
(1, 0) Attribute b prefix=|| suffix=|| indent=||
(3, 0) Attribute d prefix=|| suffix=|| indent=||
(5, 0) Attribute f prefix=|| suffix=|| indent=||
(1, 0) Name a prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(3, 0) Name c prefix=|| suffix=| | indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(5, 2) Name e prefix=|( | suffix=| )| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
20 changes: 20 additions & 0 deletions testdata/ast/golden/3.11/augassign.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
(-1, -1) Module prefix=|@@indent@@| suffix=|| indent=||
(1, 0) AugAssign prefix=|| suffix=|\n| indent=||
(3, 0) AugAssign prefix=|\n@@indent@@| suffix=|\n| indent=||
(5, 0) Expr prefix=|\n@@indent@@| suffix=|\n| indent=||
(1, 0) Name a prefix=|| suffix=| | indent=||
(-1, -1) Add prefix=|| suffix=|| indent=||
(1, 5) Name b prefix=|| suffix=|| indent=||
(3, 0) Name c prefix=|| suffix=|| indent=||
(-1, -1) Sub prefix=|| suffix=|| indent=||
(3, 3) Name d prefix=|| suffix=|| indent=||
(5, 0) Compare prefix=|| suffix=|| indent=||
(-1, -1) Store prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Store prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(5, 0) Name e prefix=|| suffix=| | indent=||
(-1, -1) LtE prefix=|| suffix=|| indent=||
(5, 8) Name f prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
78 changes: 78 additions & 0 deletions testdata/ast/golden/3.11/binop.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
(-1, -1) Module prefix=|@@indent@@| suffix=|| indent=||
(1, 0) Expr prefix=|| suffix=|\n| indent=||
(3, 0) Expr prefix=|\n@@indent@@| suffix=|\n| indent=||
(5, 0) Expr prefix=|\n@@indent@@| suffix=|\n| indent=||
(7, 0) Expr prefix=|\n@@indent@@| suffix=|\n| indent=||
(9, 0) Expr prefix=|\n@@indent@@| suffix=|\n| indent=||
(11, 0) Expr prefix=|\n@@indent@@| suffix=|\n| indent=||
(15, 0) Expr prefix=|\n@@indent@@| suffix=|\n| indent=||
(1, 0) BinOp prefix=|| suffix=|| indent=||
(3, 0) BinOp prefix=|| suffix=|| indent=||
(5, 0) BinOp prefix=|| suffix=|| indent=||
(7, 0) BinOp prefix=|| suffix=|| indent=||
(9, 0) BinOp prefix=|| suffix=|| indent=||
(12, 4) BinOp prefix=|(\n | suffix=|\n)| indent=||
(15, 1) BinOp prefix=|(| suffix=|)| indent=||
(1, 0) Name a prefix=|| suffix=| | indent=||
(-1, -1) Add prefix=|| suffix=|| indent=||
(1, 4) Name b prefix=|| suffix=|| indent=||
(3, 0) Name c prefix=|| suffix=| | indent=||
(-1, -1) Sub prefix=|| suffix=|| indent=||
(3, 4) Name d prefix=|| suffix=|| indent=||
(5, 0) Name e prefix=|| suffix=| | indent=||
(-1, -1) Div prefix=|| suffix=|| indent=||
(5, 4) Name f prefix=|| suffix=|| indent=||
(7, 0) Name g prefix=|| suffix=| | indent=||
(-1, -1) Add prefix=|| suffix=|| indent=||
(7, 5) BinOp prefix=|(| suffix=|)| indent=||
(9, 0) BinOp prefix=|| suffix=|| indent=||
(-1, -1) BitOr prefix=|| suffix=|| indent=||
(9, 25) BinOp prefix=|| suffix=|| indent=||
(12, 4) Name a prefix=|| suffix=| | indent=||
(-1, -1) Add prefix=|| suffix=|| indent=||
(12, 8) Name b prefix=|| suffix=|| indent=||
(15, 1) Name c prefix=|| suffix=| | indent=||
(-1, -1) Add prefix=|| suffix=|| indent=||
(16, 1) Name d prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(7, 5) Name h prefix=|| suffix=| | indent=||
(-1, -1) Add prefix=|| suffix=|| indent=||
(7, 9) Name i prefix=|| suffix=|| indent=||
(9, 0) BinOp prefix=|| suffix=|| indent=||
(-1, -1) BitAnd prefix=|| suffix=|| indent=||
(9, 22) Name o prefix=|| suffix=| | indent=||
(9, 25) Name p prefix=|| suffix=| | indent=||
(-1, -1) RShift prefix=|| suffix=|| indent=||
(9, 31) Name q prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(9, 0) BinOp prefix=|| suffix=| | indent=||
(-1, -1) LShift prefix=|| suffix=|| indent=||
(9, 19) Name n prefix=|| suffix=| | indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(9, 0) BinOp prefix=|| suffix=|| indent=||
(-1, -1) Add prefix=|| suffix=|| indent=||
(9, 8) BinOp prefix=|(| suffix=|)| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(9, 0) Name j prefix=|| suffix=|| indent=||
(-1, -1) FloorDiv prefix=|| suffix=|| indent=||
(9, 3) Name k prefix=|| suffix=| | indent=||
(9, 8) Name l prefix=|| suffix=| | indent=||
(-1, -1) BitXor prefix=|| suffix=|| indent=||
(9, 11) Name m prefix=|| suffix=| | indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
8 changes: 8 additions & 0 deletions testdata/ast/golden/3.11/binop3.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(-1, -1) Module prefix=|@@indent@@| suffix=|| indent=||
(1, 0) Expr prefix=|| suffix=|\n| indent=||
(1, 0) BinOp prefix=|| suffix=|| indent=||
(1, 0) Name a prefix=|| suffix=| | indent=||
(-1, -1) MatMult prefix=|| suffix=|| indent=||
(1, 4) Name b prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
54 changes: 54 additions & 0 deletions testdata/ast/golden/3.11/boolop.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
(-1, -1) Module prefix=|@@indent@@| suffix=|| indent=||
(1, 0) Expr prefix=|| suffix=|\n| indent=||
(3, 0) Expr prefix=|\n@@indent@@| suffix=|\n| indent=||
(5, 0) Expr prefix=|\n@@indent@@| suffix=|\n| indent=||
(7, 0) Expr prefix=|\n@@indent@@| suffix=|\n| indent=||
(9, 0) Expr prefix=|\n@@indent@@| suffix=|\n| indent=||
(1, 0) BoolOp prefix=|| suffix=|| indent=||
(3, 0) BoolOp prefix=|| suffix=|| indent=||
(5, 0) BoolOp prefix=|| suffix=|| indent=||
(7, 0) BoolOp prefix=|| suffix=|| indent=||
(9, 0) BoolOp prefix=|| suffix=|| indent=||
(-1, -1) And prefix=|| suffix=|| indent=||
(1, 0) Name a prefix=|| suffix=| | indent=||
(1, 6) Name b prefix=|| suffix=|| indent=||
(-1, -1) Or prefix=|| suffix=|| indent=||
(3, 0) Name c prefix=|| suffix=| | indent=||
(3, 5) Name d prefix=|| suffix=|| indent=||
(-1, -1) Or prefix=|| suffix=|| indent=||
(5, 1) BoolOp prefix=|(| suffix=|)| indent=||
(5, 20) Name h prefix=|| suffix=|| indent=||
(-1, -1) Or prefix=|| suffix=|| indent=||
(7, 0) BoolOp prefix=|| suffix=|| indent=||
(7, 20) Name k prefix=|(| suffix=|)| indent=||
(-1, -1) Or prefix=|| suffix=|| indent=||
(9, 0) BoolOp prefix=|| suffix=|| indent=||
(9, 29) Name o prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) And prefix=|| suffix=|| indent=||
(5, 1) Name e prefix=|| suffix=| | indent=||
(5, 8) BoolOp prefix=|(| suffix=|)| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) And prefix=|| suffix=|| indent=||
(7, 1) Name i prefix=|(| suffix=|)| indent=||
(7, 11) Name j prefix=|| suffix=| | indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) And prefix=|| suffix=|| indent=||
(9, 0) Name l prefix=|| suffix=| | indent=||
(9, 8) Name m prefix=|| suffix=| | indent=||
(9, 22) Name n prefix=|| suffix=| | indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Or prefix=|| suffix=|| indent=||
(5, 8) Name f prefix=|| suffix=| | indent=||
(5, 13) Name g prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
(-1, -1) Load prefix=|| suffix=|| indent=||
Loading

0 comments on commit 9af5611

Please sign in to comment.