File: check-reports.test

package info (click to toggle)
mypy 1.19.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 22,412 kB
  • sloc: python: 114,754; ansic: 13,343; cpp: 11,380; makefile: 257; sh: 28
file content (345 lines) | stat: -rw-r--r-- 9,593 bytes parent folder | download | duplicates (3)
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
[case testReportBasic]
# flags: --xml-report out
def f(): pass

def g() -> None: pass
[outfile out/index.xml]
<?xml-stylesheet type="text/xsl" href="mypy-html.xslt"?><mypy-report-index name="index"><file module="__main__" name="main" total="4" any="1" empty="2" imprecise="0" precise="1" unanalyzed="0"/></mypy-report-index>

[case testLinePrecisionBasic]
# flags: --lineprecision-report out
def f(): pass

def g() -> None:
    a = 1
[outfile out/lineprecision.txt]
Name      Lines  Precise  Imprecise  Any  Empty  Unanalyzed
-------------------------------------------------------------
__main__      5        2          0    1      2           0

[case testLinePrecisionImpreciseType]
# flags: --lineprecision-report out
def f(x: list) -> None: pass
[builtins fixtures/list.pyi]
[outfile out/lineprecision.txt]
Name      Lines  Precise  Imprecise  Any  Empty  Unanalyzed
-------------------------------------------------------------
__main__      2        0          1    0      1           0

[case testLinePrecisionUnanalyzed]
# flags: --lineprecision-report out
import sys
MYPY = False
if not MYPY:
    a = 1

def f(x: int) -> None:
    if isinstance(x, str):
        b = 1
        c = 1
[builtins fixtures/isinstance.pyi]
[outfile out/lineprecision.txt]
Name      Lines  Precise  Imprecise  Any  Empty  Unanalyzed
-------------------------------------------------------------
__main__     10        5          0    0      2           3

[case testLinePrecisionEmptyLines]
# flags: --lineprecision-report out
def f() -> None:
    """docstring

    long
    """
    x = 0

    # comment
    y = 0  # comment (non-empty)
[outfile out/lineprecision.txt]
Name      Lines  Precise  Imprecise  Any  Empty  Unanalyzed
-------------------------------------------------------------
__main__     10        3          0    0      7           0

[case testLinePrecisionImportFrom]
# flags: --lineprecision-report out --ignore-missing-imports
from m import f
from m import g
from bad import foo
from bad import (  # treated as a single line
    foo2,
    foo3,
)

[file m.py]
def f(): pass
def g() -> None: pass

[outfile out/lineprecision.txt]
Name      Lines  Precise  Imprecise  Any  Empty  Unanalyzed
-------------------------------------------------------------
__main__      8        2          0    2      4           0
m             2        1          0    1      0           0

[case testLinePrecisionImport]
# flags: --lineprecision-report out --ignore-missing-imports
import m
import bad
import m, bad

[file m.py]
[outfile out/lineprecision.txt]
Name      Lines  Precise  Imprecise  Any  Empty  Unanalyzed
-------------------------------------------------------------
__main__      4        1          0    2      1           0
m             0        0          0    0      0           0

[case testLinePrecisionStarImport]
# flags: --lineprecision-report out --ignore-missing-imports
from m import *
from bad import *

[file m.py]
def f(): pass
def g() -> None: pass
[outfile out/lineprecision.txt]
Name      Lines  Precise  Imprecise  Any  Empty  Unanalyzed
-------------------------------------------------------------
__main__      3        1          0    1      1           0
m             2        1          0    1      0           0

[case testLinePrecisionRelativeImport]
# flags: --lineprecision-report out --ignore-missing-imports
import a

[file a/__init__.py]
from .m import f
from .bad import g

[file a/m.py]
def f(): pass

[outfile out/lineprecision.txt]
Name      Lines  Precise  Imprecise  Any  Empty  Unanalyzed
-------------------------------------------------------------
__main__      2        1          0    0      1           0
a             2        1          0    1      0           0
a.m           1        0          0    1      0           0

[case testLinePrecisionPassStatement]
# flags: --lineprecision-report out
def f() -> None:
    pass
def g():
    pass
class C:
    pass
[outfile out/lineprecision.txt]
Name      Lines  Precise  Imprecise  Any  Empty  Unanalyzed
-------------------------------------------------------------
__main__      7        4          0    2      1           0

[case testLinePrecisionBreakAndContinueStatement]
# flags: --lineprecision-report out
import a
import b

[file a.py]
def f() -> int:
    while f():
        break
    return f()
def g():
    while g():
        break

[file b.py]
def f() -> int:
    while f():
        continue
    return f()
def g():
    while g():
        continue

[outfile out/lineprecision.txt]
Name      Lines  Precise  Imprecise  Any  Empty  Unanalyzed
-------------------------------------------------------------
__main__      3        2          0    0      1           0
a             7        4          0    3      0           0
b             7        4          0    3      0           0

[case testLinePrecisionLiterals]
# flags: --lineprecision-report out
import str_lit
import bytes_lit
import int_lit
import float_lit
import true_lit
import false_lit
import none_lit
import complex_lit
import dots_lit

[file str_lit.py]
def f() -> object:
    return ''
def g():
    return ''

[file bytes_lit.py]
def f() -> object:
    return b''
def g():
    return b''

[file int_lit.py]
def f() -> object:
    return 1
def g():
    return 1

[file float_lit.py]
def f() -> object:
    return 1.1
def g():
    return 1.1

[file true_lit.py]
def f() -> object:
    return True
def g():
    return True

[file false_lit.py]
def f() -> object:
    return False
def g():
    return False

[file none_lit.py]
def f() -> object:
    return None
def g():
    return None

[file complex_lit.py]
def f() -> object:
    return None
def g():
    return None

[file dots_lit.py]
def f() -> object:
    return ...
def g():
    return ...

[outfile out/lineprecision.txt]
Name         Lines  Precise  Imprecise  Any  Empty  Unanalyzed
----------------------------------------------------------------
__main__        10        9          0    0      1           0
bytes_lit        4        2          0    2      0           0
complex_lit      4        2          0    2      0           0
dots_lit         4        2          0    2      0           0
false_lit        4        2          0    2      0           0
float_lit        4        2          0    2      0           0
int_lit          4        2          0    2      0           0
none_lit         4        2          0    2      0           0
str_lit          4        2          0    2      0           0
true_lit         4        2          0    2      0           0

[case testLinePrecisionIfStatement]
# flags: --lineprecision-report out
if int():
    x = 1
else:  # This is treated as empty
    x = 2
[outfile out/lineprecision.txt]
Name      Lines  Precise  Imprecise  Any  Empty  Unanalyzed
-------------------------------------------------------------
__main__      5        3          0    0      2           0

[case testLinePrecisionCallAnyArg]
# flags: --lineprecision-report out
from m import f
def g() -> None:
    f(1)  # Precise
    f(1, 2)  # Any
[file m.py]
from typing import Any
def f(x: int, y: Any = 0) -> None:
    pass
[outfile out/lineprecision.txt]
Name      Lines  Precise  Imprecise  Any  Empty  Unanalyzed
-------------------------------------------------------------
__main__      5        3          0    1      1           0
m             3        2          0    1      0           0

[case testLinePrecisionCallImpreciseArg]
# flags: --lineprecision-report out
from m import f
def g() -> None:
    f(1)  # Precise
    f(1, [2])  # Imprecise
[file m.py]
from typing import List, Any
def f(x: int, y: List[Any] = []) -> None:
    pass
[builtins fixtures/list.pyi]
[outfile out/lineprecision.txt]
Name      Lines  Precise  Imprecise  Any  Empty  Unanalyzed
-------------------------------------------------------------
__main__      5        3          1    0      1           0
m             3        2          1    0      0           0

[case testLinePrecisionCallAnyArgWithKeywords]
# flags: --lineprecision-report out
from m import f
def g() -> None:
    f(x=1)  # Precise
    f(x=1, z=1)  # Precise
    f(z=1, x=1)  # Precise
    f(y=1)  # Any
    f(y=1, x=1)  # Any
[file m.py]
from typing import Any
def f(x: int = 0, y: Any = 0, z: int = 0) -> None:
    pass
[outfile out/lineprecision.txt]
Name      Lines  Precise  Imprecise  Any  Empty  Unanalyzed
-------------------------------------------------------------
__main__      8        5          0    2      1           0
m             3        2          0    1      0           0

[case testLinePrecisionCallAnyMethodArg]
# flags: --lineprecision-report out
from m import C
def g(c: C) -> None:
    c.f(1)  # Precise
    c.f(1, 2)  # Any
[file m.py]
from typing import Any
class C:
    def f(self, x: int, y: Any = 0) -> None:
        pass
[outfile out/lineprecision.txt]
Name      Lines  Precise  Imprecise  Any  Empty  Unanalyzed
-------------------------------------------------------------
__main__      5        3          0    1      1           0
m             4        3          0    1      0           0

[case testLinePrecisionCallAnyConstructorArg]
# flags: --lineprecision-report out
from m import C
def g() -> None:
    C(1)  # Precise
    C(1, 2)  # Any
[file m.py]
from typing import Any
class C:
    def __init__(self, x: int, y: Any = 0) -> None:
        pass
[outfile out/lineprecision.txt]
Name      Lines  Precise  Imprecise  Any  Empty  Unanalyzed
-------------------------------------------------------------
__main__      5        3          0    1      1           0
m             4        3          0    1      0           0