From 4d03716eaea58ee38d77cf2bba0a72b7a27ec9fa Mon Sep 17 00:00:00 2001
From: Richard Si <63936253+ichard26@users.noreply.github.com>
Date: Tue, 24 Nov 2020 04:39:25 -0500
Subject: [PATCH] Allow same RHS expressions in annotated assignments as in
 regular assignments (#1835)

---
 CHANGES.md               |  3 +++
 src/blib2to3/Grammar.txt |  2 +-
 tests/data/python38.py   | 18 ++++++++++++++++++
 3 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/CHANGES.md b/CHANGES.md
index 67697bd..ca8a047 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -21,6 +21,9 @@
 
 - Added support for PEP 614 relaxed decorator syntax on python 3.9 (#1711)
 
+- Added parsing support for unparenthesized tuples and yield expressions in annotated
+  assignments (#1835)
+
 - use lowercase hex strings (#1692)
 
 #### _Packaging_
diff --git a/src/blib2to3/Grammar.txt b/src/blib2to3/Grammar.txt
index eafaee8..69b9af9 100644
--- a/src/blib2to3/Grammar.txt
+++ b/src/blib2to3/Grammar.txt
@@ -77,7 +77,7 @@ small_stmt: (expr_stmt | print_stmt  | del_stmt | pass_stmt | flow_stmt |
              import_stmt | global_stmt | exec_stmt | assert_stmt)
 expr_stmt: testlist_star_expr (annassign | augassign (yield_expr|testlist) |
                      ('=' (yield_expr|testlist_star_expr))*)
-annassign: ':' test ['=' test]
+annassign: ':' test ['=' (yield_expr|testlist_star_expr)]
 testlist_star_expr: (test|star_expr) (',' (test|star_expr))* [',']
 augassign: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' |
             '<<=' | '>>=' | '**=' | '//=')
diff --git a/tests/data/python38.py b/tests/data/python38.py
index 1a7f761..63b0588 100644
--- a/tests/data/python38.py
+++ b/tests/data/python38.py
@@ -11,6 +11,14 @@ def starred_yield():
     yield "value1", *my_list
 
 
+# all right hand side expressions allowed in regular assignments are now also allowed in
+# annotated assignments
+a : Tuple[ str, int] = "1", 2
+a: Tuple[int , ... ] = b,  *c, d
+def t():
+    a : str =  yield "a"
+
+
 # output
 
 
@@ -25,3 +33,13 @@ def starred_return():
 def starred_yield():
     my_list = ["value2", "value3"]
     yield "value1", *my_list
+
+
+# all right hand side expressions allowed in regular assignments are now also allowed in
+# annotated assignments
+a: Tuple[str, int] = "1", 2
+a: Tuple[int, ...] = b, *c, d
+
+
+def t():
+    a: str = yield "a"
-- 
2.39.5