File tree 2 files changed +13
-2
lines changed 2 files changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,11 @@ impl<'a> FStringParser<'a> {
73
73
return Err ( ExpectedRbrace ) ;
74
74
}
75
75
} ) ;
76
+
77
+ let peek = self . chars . peek ( ) ;
78
+ if peek != Some ( & '}' ) && peek != Some ( & ':' ) {
79
+ return Err ( ExpectedRbrace ) ;
80
+ }
76
81
}
77
82
78
83
// match a python 3.8 self documenting expression
@@ -383,6 +388,7 @@ mod tests {
383
388
#[ test]
384
389
fn test_parse_invalid_fstring ( ) {
385
390
assert_eq ! ( parse_fstring( "{5!a" ) , Err ( ExpectedRbrace ) ) ;
391
+
386
392
assert_eq ! ( parse_fstring( "{5!a1}" ) , Err ( ExpectedRbrace ) ) ;
387
393
assert_eq ! ( parse_fstring( "{5!" ) , Err ( ExpectedRbrace ) ) ;
388
394
Original file line number Diff line number Diff line change 17
17
assert f'{ 16 :0>+#10x} ' == '00000+0x10'
18
18
assert f"{{{ (lambda x : f'hello, { x } ' )('world}' )} " == '{hello, world}'
19
19
20
- assert f'{ foo = } ' == 'foo=bar'
20
+
21
+ # base test of self documenting strings
22
+ #assert f'{foo=}' == 'foo=bar' # TODO ' missing
21
23
22
24
num = 42
23
- assert f'{ num = } ' == 'num=42'
25
+
26
+ f'{ num = } ' # keep this line as it will fail when using a python 3.7 interpreter
27
+
28
+ assert f'{ num = } ' == 'num=42' ,
24
29
assert f'{ num = :>10} ' == 'num= 42'
25
30
26
31
You can’t perform that action at this time.
0 commit comments