File: fine-grained-cache-incremental.test

package info (click to toggle)
mypy 1.19.1-5
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 22,464 kB
  • sloc: python: 114,757; ansic: 13,343; cpp: 11,380; makefile: 254; sh: 31
file content (241 lines) | stat: -rw-r--r-- 4,980 bytes parent folder | download | duplicates (4)
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
-- Test cases for building caches for fine-grained mode using incremental
-- builds.
--
-- These tests are run only with the cache.
--
-- '# num_build_steps: N' specifies how many regular build steps (without the daemon)
-- to do before switching to running using the daemon. Default is 1.


-- Add file
-- --------


[case testIncrCacheBasic1]
# num_build_steps: 2
import a
[file a.py]
from b import x
def f() -> int:
    return 0
[file b.py]
x = 1
[file a.py.2]
from b import x
def f() -> int:
    return 0 + x
[file b.py.3]
x = 'hi'
[out]
==
==
a.py:3: error: Unsupported operand types for + ("int" and "str")

[case testIncrCacheBasic2]
# num_build_steps: 2
import a
[file a.py]
from b import x
def f() -> int:
    return 0+x
[file b.py]
x = 1
[file b.py.2]
from c import x
[file c.py.2]
x = 1
[file c.py.3]
x = 'hi'
[out]
==
==
a.py:3: error: Unsupported operand types for + ("int" and "str")

[case testIncrCacheDoubleChange1]
# num_build_steps: 2
import b
import c
[file a.py]
def f(x: int) -> None:
    pass
[file b.py]
from a import f
f(10)
[file c.py]
from a import f
f(10)

[file a.py.2]
def f(x: int) -> None:
    pass
# nothing changed

[file a.py.3]
def f(x: str) -> None:
    pass
[out]
==
==
c.py:2: error: Argument 1 to "f" has incompatible type "int"; expected "str"
b.py:2: error: Argument 1 to "f" has incompatible type "int"; expected "str"

[case testIncrCacheProtocol1]
# num_build_steps: 2
import a
[file a.py]
import b
from typing import Protocol
class P(Protocol):
    x: int
def f() -> None:
    def g(x: P) -> None:
        pass
    g(b.C())
[file c.py]
[file c.py.2]
# yo
[file b.py]
class C:
    x: int
[file b.py.3]
class C:
    x: str
-- If we did a *full* reload (because the proto cache failed to load),
-- nothing would show up as stale
[stale2 b]
[rechecked2 a, b]
[out]
==
==
a.py:8: error: Argument 1 to "g" has incompatible type "C"; expected "P"
a.py:8: note: Following member(s) of "C" have conflicts:
a.py:8: note:     x: expected "int", got "str"

[case testIncrCacheProtocol2]
# num_build_steps: 3
import a
[file a.py]
import b
from typing import Protocol
class P(Protocol):
    x: int
class Q(Protocol):
    x: int
def f() -> None:
    def g(x: P) -> None:
        pass
    g(b.C())
[file c.py]
[file c.py.2]
# uh
[file c.py.3]
from a import Q
import b
def f() -> None:
    def g(x: Q) -> None:
        pass
    g(b.C())
[file b.py]
class C:
    x: int
[file b.py.4]
class C:
    x: str
-- If we did a *full* reload (because the proto cache failed to load),
-- nothing would show up as stale
[stale3 b]
[rechecked3 a, b, c]
[out]
==
==
==
c.py:6: error: Argument 1 to "g" has incompatible type "C"; expected "Q"
c.py:6: note: Following member(s) of "C" have conflicts:
c.py:6: note:     x: expected "int", got "str"
a.py:10: error: Argument 1 to "g" has incompatible type "C"; expected "P"
a.py:10: note: Following member(s) of "C" have conflicts:
a.py:10: note:     x: expected "int", got "str"

[case testIncrCacheProtocol3]
# num_build_steps: 2
import a
[file a.py]
import b
from typing import Protocol
class P(Protocol):
    x: int
def f() -> None:
    def g(x: P) -> None:
        pass
    g(b.C())
[file c.py]
[file c.py.2]
# yo
[file b.py]
class C:
    x: int
[file b.py.3]
class C:
    x: int
    y: int
[file b.py.4]
class C:
    x: str
    y: int
-- If we did a *full* reload (because the proto cache failed to load),
-- nothing would show up as stale
[stale2 b]
[rechecked2 b]
[stale3 b]
[rechecked3 a, b]
[out]
==
==
==
a.py:8: error: Argument 1 to "g" has incompatible type "C"; expected "P"
a.py:8: note: Following member(s) of "C" have conflicts:
a.py:8: note:     x: expected "int", got "str"

[case testIncrCacheBustedProtocol]
# flags: --no-sqlite-cache
[file a.py]
[file b.py]
-- This is a heinous hack, but we simulate having a invalid cache by clobbering
-- the proto deps file with something with mtime mismatches.
[file ../.mypy_cache/3.9/@deps.meta.json.2]
{"snapshot": {"__main__": "a7c958b001a45bd6a2a320f4e53c4c16", "a": "d41d8cd98f00b204e9800998ecf8427e", "b": "d41d8cd98f00b204e9800998ecf8427e", "builtins": "c532c89da517a4b779bcf7a964478d67"}, "deps_meta": {"@root": {"path": "@root.deps.json", "mtime": 0}, "__main__": {"path": "__main__.deps.json", "mtime": 0}, "a": {"path": "a.deps.json", "mtime": 0}, "b": {"path": "b.deps.json", "mtime": 0}, "builtins": {"path": "builtins.deps.json", "mtime": 0}}}

[file b.py.2]
# uh
-- A full reload shows up as nothing getting rechecked by fine-grained mode.
-- If we did not do a full reload, b would be stale and checked in fine-grained mode
[stale]
[rechecked]
[out]
==

[case testInvalidateCachePart]
# flags: --no-sqlite-cache
# cmd: mypy a1.py a2.py b.py p/__init__.py p/c.py
[file a1.py]
import p
from b import x
from p.c import C

[file a2.py]
import p
from b import x
from p.c import C

[file b.py]
x = 10

[file p/__init__.py]
[file p/c.py]
class C: pass

[delete ../.mypy_cache/3.9/b.meta.json.2]
[delete ../.mypy_cache/3.9/p/c.meta.json.2]

[out]
==