]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Allow same RHS expressions in annotated assignments as in regular assignments (#1835)
authorRichard Si <63936253+ichard26@users.noreply.github.com>
Tue, 24 Nov 2020 09:39:25 +0000 (04:39 -0500)
committerGitHub <noreply@github.com>
Tue, 24 Nov 2020 09:39:25 +0000 (09:39 +0000)
CHANGES.md
src/blib2to3/Grammar.txt
tests/data/python38.py

index 67697bd7b074e1b2bf0367acedd313effa9df61f..ca8a0472a3bbc6ccf2d55fe3e4851b256140b7f8 100644 (file)
@@ -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_
index eafaee84cb36157ae7fee6763d62031858ad63a9..69b9af966086b5bb18282042e2053efdaf002a21 100644 (file)
@@ -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: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' |
             '<<=' | '>>=' | '**=' | '//=')
index 1a7f76167d9167b8e9a8ca446d1047aacb0c6a85..63b0588bc27a1affe2d5a955537728ad8f95f5be 100644 (file)
@@ -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"