-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Expand file tree
/
Copy pathcheck-python314.test
More file actions
53 lines (46 loc) · 1.38 KB
/
check-python314.test
File metadata and controls
53 lines (46 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
[case testTemplateStringBasics]
reveal_type(t"foobar") # N: Revealed type is "string.templatelib.Template"
t"{'foobar'}"
t"foo{'bar'}"
t".{1}."
t"{type(1)}"
t"{1!r}"
t"{1:03d}"
t"{1!r:03d}"
from string.templatelib import Template
a: Template
a = t"foobar"
a = t"{'foobar'}"
[builtins fixtures/f_string.pyi]
[case testTemplateStringWithoutExplicitImport]
reveal_type(t"implicit import works") # N: Revealed type is "string.templatelib.Template"
[builtins fixtures/f_string.pyi]
[case testTemplateStringExpressionsOk]
t".{1 + 1}."
t".{1 + 1}.{'foo' + 'bar'}"
[builtins fixtures/f_string.pyi]
[case testTemplateStringExpressionsErrors]
t"{1 + ''}" # E: Unsupported operand types for + ("int" and "str")
t".{1 + ''}" # E: Unsupported operand types for + ("int" and "str")
[builtins fixtures/f_string.pyi]
[case testTemplateStringParseFormatOptions]
value = 10.5142
width = 10
precision = 4
t"result: {value:{width}.{precision}}"
[builtins fixtures/f_string.pyi]
[case testTemplateStringNestedExpressionsTypeChecked]
t"{2:{3 + ''}}" # E: Unsupported operand types for + ("int" and "str")
[builtins fixtures/f_string.pyi]
[case testIncrementalTemplateStringImplicitDependency]
import m
reveal_type(m.x)
[file m.py]
x = "foo"
[file m.py.2]
x = t"foo"
[out1]
main:2: note: Revealed type is "builtins.str"
[out2]
main:2: note: Revealed type is "string.templatelib.Template"
[builtins fixtures/f_string.pyi]