Unverified Commit 4d03716e authored by Richard Si's avatar Richard Si Committed by GitHub
Browse files

Allow same RHS expressions in annotated assignments as in regular assignments (#1835)

parent dea81b7a
Loading
Loading
Loading
Loading
+3 −0
Changes for CHANGES.md: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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_
+1 −1
Changes for src/blib2to3/Grammar.txt: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -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: ('+=' | '-=' | '*=' | '@=' | '/=' | '%=' | '&=' | '|=' | '^=' |
            '<<=' | '>>=' | '**=' | '//=')
+18 −0
Changes for tests/data/python38.py: 18 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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"