File tree Expand file tree Collapse file tree 3 files changed +298
-199
lines changed Expand file tree Collapse file tree 3 files changed +298
-199
lines changed Original file line number Diff line number Diff line change
1
+ # These are shared with test_tokenize and other test modules.
2
+ #
3
+ # Note: since several test cases filter out floats by looking for "e" and ".",
4
+ # don't add hexadecimal literals that contain "e" or "E".
5
+ VALID_UNDERSCORE_LITERALS = [
6
+ '0_0_0' ,
7
+ '4_2' ,
8
+ '1_0000_0000' ,
9
+ '0b1001_0100' ,
10
+ '0xffff_ffff' ,
11
+ '0o5_7_7' ,
12
+ '1_00_00.5' ,
13
+ '1_00_00.5e5' ,
14
+ '1_00_00e5_1' ,
15
+ '1e1_0' ,
16
+ '.1_4' ,
17
+ '.1_4e1' ,
18
+ '0b_0' ,
19
+ '0x_f' ,
20
+ '0o_5' ,
21
+ '1_00_00j' ,
22
+ '1_00_00.5j' ,
23
+ '1_00_00e5_1j' ,
24
+ '.1_4j' ,
25
+ '(1_2.5+3_3j)' ,
26
+ '(.5_6j)' ,
27
+ ]
28
+ INVALID_UNDERSCORE_LITERALS = [
29
+ # Trailing underscores:
30
+ '0_' ,
31
+ '42_' ,
32
+ '1.4j_' ,
33
+ '0x_' ,
34
+ '0b1_' ,
35
+ '0xf_' ,
36
+ '0o5_' ,
37
+ '0 if 1_Else 1' ,
38
+ # Underscores in the base selector:
39
+ '0_b0' ,
40
+ '0_xf' ,
41
+ '0_o5' ,
42
+ # Old-style octal, still disallowed:
43
+ '0_7' ,
44
+ '09_99' ,
45
+ # Multiple consecutive underscores:
46
+ '4_______2' ,
47
+ '0.1__4' ,
48
+ '0.1__4j' ,
49
+ '0b1001__0100' ,
50
+ '0xffff__ffff' ,
51
+ '0x___' ,
52
+ '0o5__77' ,
53
+ '1e1__0' ,
54
+ '1e1__0j' ,
55
+ # Underscore right before a dot:
56
+ '1_.4' ,
57
+ '1_.4j' ,
58
+ # Underscore right after a dot:
59
+ '1._4' ,
60
+ '1._4j' ,
61
+ '._5' ,
62
+ '._5j' ,
63
+ # Underscore right after a sign:
64
+ '1.0e+_1' ,
65
+ '1.0e+_1j' ,
66
+ # Underscore right before j:
67
+ '1.4_j' ,
68
+ '1.4e5_j' ,
69
+ # Underscore right before e:
70
+ '1_e1' ,
71
+ '1.4_e1' ,
72
+ '1.4_e1j' ,
73
+ # Underscore right after e:
74
+ '1e_1' ,
75
+ '1.4e_1' ,
76
+ '1.4e_1j' ,
77
+ # Complex cases with parens:
78
+ '(1+1.5_j_)' ,
79
+ '(1+1.5_j)' ,
80
+ ]
You can’t perform that action at this time.
0 commit comments