@@ -2686,6 +2686,71 @@ def f(x: *b)
26862686 >>> f(x = 5, *:)
26872687 Traceback (most recent call last):
26882688 SyntaxError: Invalid star expression
2689+
2690+ Asserts:
2691+
2692+ >>> assert (a := 1) # ok
2693+ >>> # TODO(@sobolevn): improve this message in the next PR
2694+ >>> assert a := 1
2695+ Traceback (most recent call last):
2696+ SyntaxError: invalid syntax
2697+
2698+ >>> assert 1 = 2 = 3
2699+ Traceback (most recent call last):
2700+ SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?
2701+
2702+ >>> assert 1 = 2
2703+ Traceback (most recent call last):
2704+ SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?
2705+
2706+ >>> assert (1 = 2)
2707+ Traceback (most recent call last):
2708+ SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?
2709+
2710+ >>> assert 'a' = a
2711+ Traceback (most recent call last):
2712+ SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?
2713+
2714+ >>> assert x[0] = 1
2715+ Traceback (most recent call last):
2716+ SyntaxError: cannot assign to subscript here. Maybe you meant '==' instead of '='?
2717+
2718+ >>> assert (yield a) = 2
2719+ Traceback (most recent call last):
2720+ SyntaxError: cannot assign to yield expression here. Maybe you meant '==' instead of '='?
2721+
2722+ >>> assert a = 2
2723+ Traceback (most recent call last):
2724+ SyntaxError: cannot assign to name here. Maybe you meant '==' instead of '='?
2725+
2726+ >>> assert (a = 2)
2727+ Traceback (most recent call last):
2728+ SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
2729+
2730+ >>> assert a = b
2731+ Traceback (most recent call last):
2732+ SyntaxError: cannot assign to name here. Maybe you meant '==' instead of '='?
2733+
2734+ >>> assert 1, 1 = b
2735+ Traceback (most recent call last):
2736+ SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?
2737+
2738+ >>> assert 1, (1 = b)
2739+ Traceback (most recent call last):
2740+ SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?
2741+
2742+ >>> assert 1, a = 1
2743+ Traceback (most recent call last):
2744+ SyntaxError: cannot assign to name here. Maybe you meant '==' instead of '='?
2745+
2746+ >>> assert 1, (a = 1)
2747+ Traceback (most recent call last):
2748+ SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
2749+
2750+ >>> assert 1 = a, a = 1
2751+ Traceback (most recent call last):
2752+ SyntaxError: cannot assign to literal here. Maybe you meant '==' instead of '='?
2753+
26892754"""
26902755
26912756import re
0 commit comments