with self.assertRaisesRegex(SyntaxError,
"f-string: expecting '=', or '!', or ':', or '}'"):
compile("f'{a $ b}'", "?", "exec")
+ with self.assertRaisesRegex(SyntaxError,
+ "f-string: expecting '!', or ':', or '}'"):
+ compile("f'{a=b}'", "?", "exec")
def test_with_two_commas_in_format_specifier(self):
error_msg = re.escape("Cannot specify ',' with ','.")
Traceback (most recent call last):
SyntaxError: only single target (not list) can be annotated
+>>> 1: int
+Traceback (most recent call last):
+SyntaxError: illegal target for annotation
+>>> -x: int = 1
+Traceback (most recent call last):
+SyntaxError: illegal target for annotation
+>>> (x for x in y): int
+Traceback (most recent call last):
+SyntaxError: illegal target for annotation
+
# 'not' after operators:
>>> 3 + not 3
^^^
SyntaxError: cannot use dict unpacking in a dictionary value
+ >>> (**a)
+ Traceback (most recent call last):
+ ...
+ (**a)
+ ^^
+ SyntaxError: cannot use dict unpacking here
+
+ >>> {**a for a in {1: 2}.items(): b}
+ Traceback (most recent call last):
+ ...
+ {**a for a in {1: 2}.items(): b}
+ ^^
+ SyntaxError: cannot use dict unpacking here
+
# Generator expression in function arguments