File tree Expand file tree Collapse file tree 4 files changed +262
-173
lines changed
Misc/NEWS.d/next/Core_and_Builtins Expand file tree Collapse file tree 4 files changed +262
-173
lines changed Original file line number Diff line number Diff line change @@ -1315,6 +1315,14 @@ invalid_assert_stmt:
13151315 a, b,
13161316 "cannot assign to %s here. Maybe you meant '==' instead of '='?",
13171317 _PyPegen_get_expr_name(a)) }
1318+ | 'assert' a=expression ':=' b=expression {
1319+ RAISE_SYNTAX_ERROR_KNOWN_RANGE(
1320+ a, b,
1321+ "cannot use named expression without parentheses here") }
1322+ | 'assert' expression ',' a=expression ':=' b=expression {
1323+ RAISE_SYNTAX_ERROR_KNOWN_RANGE(
1324+ a, b,
1325+ "cannot use named expression without parentheses here") }
13181326invalid_block:
13191327 | NEWLINE !INDENT { RAISE_INDENTATION_ERROR("expected an indented block") }
13201328invalid_comprehension:
Original file line number Diff line number Diff line change @@ -2690,10 +2690,15 @@ def f(x: *b)
26902690Asserts:
26912691
26922692 >>> assert (a := 1) # ok
2693- >>> # TODO(@sobolevn): improve this message in the next PR
2693+ >>> assert 1, (a := 1) # ok
2694+
26942695 >>> assert a := 1
26952696 Traceback (most recent call last):
2696- SyntaxError: invalid syntax
2697+ SyntaxError: cannot use named expression without parentheses here
2698+
2699+ >>> assert 1, a := 1
2700+ Traceback (most recent call last):
2701+ SyntaxError: cannot use named expression without parentheses here
26972702
26982703 >>> assert 1 = 2 = 3
26992704 Traceback (most recent call last):
Original file line number Diff line number Diff line change 1+ Improve :exc: `SyntaxError ` message for :keyword: `assert ` in cases like
2+ ``assert a := b ``.
You can’t perform that action at this time.
0 commit comments