| 1 |
[case testTemplateStringSimple] |
| 2 |
x = 'mypy' |
| 3 |
t'Hello {x}' |
| 4 |
[out] |
| 5 |
MypyFile:1( |
| 6 |
AssignmentStmt:1( |
| 7 |
NameExpr(x) |
| 8 |
StrExpr(mypy)) |
| 9 |
ExpressionStmt:2( |
| 10 |
TemplateStrExpr:2( |
| 11 |
StrExpr(Hello ) |
| 12 |
Interpolation( |
| 13 |
Value( |
| 14 |
NameExpr(x)) |
| 15 |
Source('x') |
| 16 |
Conversion(None) |
| 17 |
FormatSpec(None))))) |
| 18 |
|
| 19 |
[case testTemplateStringWithComplexExpression] |
| 20 |
x = 1 |
| 21 |
y = 2 |
| 22 |
t'Hello {x + y}' |
| 23 |
[out] |
| 24 |
MypyFile:1( |
| 25 |
AssignmentStmt:1( |
| 26 |
NameExpr(x) |
| 27 |
IntExpr(1)) |
| 28 |
AssignmentStmt:2( |
| 29 |
NameExpr(y) |
| 30 |
IntExpr(2)) |
| 31 |
ExpressionStmt:3( |
| 32 |
TemplateStrExpr:3( |
| 33 |
StrExpr(Hello ) |
| 34 |
Interpolation( |
| 35 |
Value( |
| 36 |
OpExpr:3( |
| 37 |
+ |
| 38 |
NameExpr(x) |
| 39 |
NameExpr(y))) |
| 40 |
Source('x + y') |
| 41 |
Conversion(None) |
| 42 |
FormatSpec(None))))) |
| 43 |
|
| 44 |
[case testTemplateStringWithConversion] |
| 45 |
x = 'mypy' |
| 46 |
T'Hello {x!r}' |
| 47 |
[out] |
| 48 |
MypyFile:1( |
| 49 |
AssignmentStmt:1( |
| 50 |
NameExpr(x) |
| 51 |
StrExpr(mypy)) |
| 52 |
ExpressionStmt:2( |
| 53 |
TemplateStrExpr:2( |
| 54 |
StrExpr(Hello ) |
| 55 |
Interpolation( |
| 56 |
Value( |
| 57 |
NameExpr(x)) |
| 58 |
Source('x') |
| 59 |
Conversion('r') |
| 60 |
FormatSpec(None))))) |
| 61 |
|
| 62 |
[case testTemplateStringWithOnlyFormatSpecifier] |
| 63 |
x = 'mypy' |
| 64 |
t'Hello {x:<30}' |
| 65 |
[out] |
| 66 |
MypyFile:1( |
| 67 |
AssignmentStmt:1( |
| 68 |
NameExpr(x) |
| 69 |
StrExpr(mypy)) |
| 70 |
ExpressionStmt:2( |
| 71 |
TemplateStrExpr:2( |
| 72 |
StrExpr(Hello ) |
| 73 |
Interpolation( |
| 74 |
Value( |
| 75 |
NameExpr(x)) |
| 76 |
Source('x') |
| 77 |
Conversion(None) |
| 78 |
FormatSpec( |
| 79 |
StrExpr(<30)))))) |
| 80 |
|
| 81 |
[case testTemplateStringWithFormatSpecifierAndConversion] |
| 82 |
x = 'mypy' |
| 83 |
t'Hello {x!s:<30}' |
| 84 |
[out] |
| 85 |
MypyFile:1( |
| 86 |
AssignmentStmt:1( |
| 87 |
NameExpr(x) |
| 88 |
StrExpr(mypy)) |
| 89 |
ExpressionStmt:2( |
| 90 |
TemplateStrExpr:2( |
| 91 |
StrExpr(Hello ) |
| 92 |
Interpolation( |
| 93 |
Value( |
| 94 |
NameExpr(x)) |
| 95 |
Source('x') |
| 96 |
Conversion('s') |
| 97 |
FormatSpec( |
| 98 |
StrExpr(<30)))))) |
| 99 |
|
| 100 |
[case testTemplateStringWithFormatSpecifierExpression] |
| 101 |
x = 'mypy' |
| 102 |
y = 30 |
| 103 |
t'Hello {x!s:<{y+y}}' |
| 104 |
[out] |
| 105 |
MypyFile:1( |
| 106 |
AssignmentStmt:1( |
| 107 |
NameExpr(x) |
| 108 |
StrExpr(mypy)) |
| 109 |
AssignmentStmt:2( |
| 110 |
NameExpr(y) |
| 111 |
IntExpr(30)) |
| 112 |
ExpressionStmt:3( |
| 113 |
TemplateStrExpr:3( |
| 114 |
StrExpr(Hello ) |
| 115 |
Interpolation( |
| 116 |
Value( |
| 117 |
NameExpr(x)) |
| 118 |
Source('x') |
| 119 |
Conversion('s') |
| 120 |
FormatSpec( |
| 121 |
CallExpr:3( |
| 122 |
MemberExpr:3( |
| 123 |
StrExpr() |
| 124 |
join) |
| 125 |
Args( |
| 126 |
ListExpr:3( |
| 127 |
StrExpr(<) |
| 128 |
CallExpr:3( |
| 129 |
MemberExpr:3( |
| 130 |
StrExpr({:{}}) |
| 131 |
format) |
| 132 |
Args( |
| 133 |
OpExpr:3( |
| 134 |
+ |
| 135 |
NameExpr(y) |
| 136 |
NameExpr(y)) |
| 137 |
StrExpr())))))))))) |