@@ -1058,7 +1058,7 @@ class A:
1058
1058
class A:
1059
1059
def bar(self): pass
1060
1060
[rechecked m, n]
1061
- [stale m, n]
1061
+ [stale n]
1062
1062
[out1]
1063
1063
main:2: error: "A" has no attribute "bar"
1064
1064
@@ -1149,6 +1149,214 @@ def C() -> str:
1149
1149
main:1: note: In module imported here:
1150
1150
tmp/m1.py:3: error: Argument 1 to "accepts_int" has incompatible type "str"; expected "int"
1151
1151
1152
+ [case testIncrementalSilentImportsWithBlatantError]
1153
+ # cmd: mypy -m main
1154
+ # flags: --silent-imports
1155
+
1156
+ [file main.py]
1157
+ from evil import Hello
1158
+
1159
+ [file main.py.next]
1160
+ from evil import Hello
1161
+ reveal_type(Hello())
1162
+
1163
+ [file evil.py]
1164
+ def accept_int(x: int) -> None: pass
1165
+ accept_int("not an int")
1166
+
1167
+ [rechecked main]
1168
+ [stale]
1169
+ [out2]
1170
+ tmp/main.py:2: error: Revealed type is 'Any'
1171
+
1172
+ [case testIncrementalImportIsNewlySilenced]
1173
+ # cmd: mypy -m main foo
1174
+ # cmd2: mypy -m main
1175
+ # flags: --silent-imports
1176
+
1177
+ [file main.py]
1178
+ from foo import bar
1179
+ def accept_int(x: int) -> None: pass
1180
+ accept_int(bar)
1181
+
1182
+ [file foo.py]
1183
+ bar = 3
1184
+
1185
+ [file foo.py.next]
1186
+ # Empty!
1187
+
1188
+ [rechecked main]
1189
+ [stale main]
1190
+
1191
+ [case testIncrementalSilencedModuleNoLongerCausesError]
1192
+ # cmd: mypy -m main evil
1193
+ # cmd2: mypy -m main
1194
+ # flags: --silent-imports
1195
+
1196
+ [file main.py]
1197
+ from evil import bar
1198
+ def accept_int(x: int) -> None: pass
1199
+ accept_int(bar)
1200
+ reveal_type(bar)
1201
+
1202
+ [file evil.py]
1203
+ bar = "str"
1204
+
1205
+ [rechecked main]
1206
+ [stale]
1207
+ [out1]
1208
+ tmp/main.py:3: error: Argument 1 to "accept_int" has incompatible type "str"; expected "int"
1209
+ tmp/main.py:4: error: Revealed type is 'builtins.str'
1210
+ [out2]
1211
+ tmp/main.py:4: error: Revealed type is 'Any'
1212
+
1213
+ [case testIncrementalFixedBugCausesPropagation]
1214
+ import mod1
1215
+
1216
+ [file mod1.py]
1217
+ from mod2 import A
1218
+ val = A().makeB().makeC().foo()
1219
+ reveal_type(val)
1220
+
1221
+ [file mod2.py]
1222
+ from mod3 import B
1223
+ class A:
1224
+ def makeB(self) -> B: return B()
1225
+
1226
+ [file mod3.py]
1227
+ from mod4 import C
1228
+ class B:
1229
+ def makeC(self) -> C:
1230
+ val = 3 # type: int
1231
+ val = "str" # deliberately triggering error
1232
+ return C()
1233
+
1234
+ [file mod3.py.next]
1235
+ from mod4 import C
1236
+ class B:
1237
+ def makeC(self) -> C: return C()
1238
+
1239
+ [file mod4.py]
1240
+ class C:
1241
+ def foo(self) -> int: return 1
1242
+
1243
+ [rechecked mod3, mod2, mod1]
1244
+ [stale mod3, mod2]
1245
+ [out1]
1246
+ tmp/mod2.py:1: note: In module imported here,
1247
+ tmp/mod1.py:1: note: ... from here,
1248
+ main:1: note: ... from here:
1249
+ tmp/mod3.py: note: In member "makeC" of class "B":
1250
+ tmp/mod3.py:5: error: Incompatible types in assignment (expression has type "str", variable has type "int")
1251
+ main:1: note: In module imported here:
1252
+ tmp/mod1.py: note: At top level:
1253
+ tmp/mod1.py:3: error: Revealed type is 'builtins.int'
1254
+
1255
+ [out2]
1256
+ main:1: note: In module imported here:
1257
+ tmp/mod1.py:3: error: Revealed type is 'builtins.int'
1258
+
1259
+ [case testIncrementalIncidentalChangeWithBugCausesPropagation]
1260
+ import mod1
1261
+
1262
+ [file mod1.py]
1263
+ from mod2 import A
1264
+ val = A().makeB().makeC().foo()
1265
+ reveal_type(val)
1266
+
1267
+ [file mod2.py]
1268
+ from mod3 import B
1269
+ class A:
1270
+ def makeB(self) -> B: return B()
1271
+
1272
+ [file mod3.py]
1273
+ from mod4 import C
1274
+ class B:
1275
+ def makeC(self) -> C:
1276
+ val = 3 # type: int
1277
+ val = "str" # deliberately triggering error
1278
+ return C()
1279
+
1280
+ [file mod4.py]
1281
+ class C:
1282
+ def foo(self) -> int: return 1
1283
+
1284
+ [file mod4.py.next]
1285
+ class C:
1286
+ def foo(self) -> str: return 'a'
1287
+
1288
+ [rechecked mod4, mod3, mod2, mod1]
1289
+ [stale mod4]
1290
+ [out1]
1291
+ tmp/mod2.py:1: note: In module imported here,
1292
+ tmp/mod1.py:1: note: ... from here,
1293
+ main:1: note: ... from here:
1294
+ tmp/mod3.py: note: In member "makeC" of class "B":
1295
+ tmp/mod3.py:5: error: Incompatible types in assignment (expression has type "str", variable has type "int")
1296
+ main:1: note: In module imported here:
1297
+ tmp/mod1.py: note: At top level:
1298
+ tmp/mod1.py:3: error: Revealed type is 'builtins.int'
1299
+
1300
+ [out2]
1301
+ tmp/mod2.py:1: note: In module imported here,
1302
+ tmp/mod1.py:1: note: ... from here,
1303
+ main:1: note: ... from here:
1304
+ tmp/mod3.py: note: In member "makeC" of class "B":
1305
+ tmp/mod3.py:5: error: Incompatible types in assignment (expression has type "str", variable has type "int")
1306
+ main:1: note: In module imported here:
1307
+ tmp/mod1.py: note: At top level:
1308
+ tmp/mod1.py:3: error: Revealed type is 'builtins.str'
1309
+
1310
+ [case testIncrementalIncidentalChangeWithBugFixCausesPropagation]
1311
+ import mod1
1312
+
1313
+ [file mod1.py]
1314
+ from mod2 import A
1315
+ val = A().makeB().makeC().foo()
1316
+ reveal_type(val)
1317
+
1318
+ [file mod2.py]
1319
+ from mod3 import B
1320
+ class A:
1321
+ def makeB(self) -> B: return B()
1322
+
1323
+ [file mod3.py]
1324
+ from mod4 import C
1325
+ class B:
1326
+ def makeC(self) -> C:
1327
+ val = 3 # type: int
1328
+ val = "str" # deliberately triggering error
1329
+ return C()
1330
+
1331
+ [file mod3.py.next]
1332
+ from mod4 import C
1333
+ class B:
1334
+ def makeC(self) -> C: return C()
1335
+
1336
+ [file mod4.py]
1337
+ class C:
1338
+ def foo(self) -> int: return 1
1339
+
1340
+ [file mod4.py.next]
1341
+ class C:
1342
+ def foo(self) -> str: return 'a'
1343
+
1344
+ [rechecked mod4, mod3, mod2, mod1]
1345
+ [stale mod4, mod3, mod2]
1346
+ [out1]
1347
+ tmp/mod2.py:1: note: In module imported here,
1348
+ tmp/mod1.py:1: note: ... from here,
1349
+ main:1: note: ... from here:
1350
+ tmp/mod3.py: note: In member "makeC" of class "B":
1351
+ tmp/mod3.py:5: error: Incompatible types in assignment (expression has type "str", variable has type "int")
1352
+ main:1: note: In module imported here:
1353
+ tmp/mod1.py: note: At top level:
1354
+ tmp/mod1.py:3: error: Revealed type is 'builtins.int'
1355
+
1356
+ [out2]
1357
+ main:1: note: In module imported here:
1358
+ tmp/mod1.py:3: error: Revealed type is 'builtins.str'
1359
+
1152
1360
[case testIncrementalSilentImportsWithInnerImports]
1153
1361
# cmd: mypy -m main foo
1154
1362
# flags: --silent-imports
@@ -1170,7 +1378,7 @@ class MyClass:
1170
1378
1171
1379
[rechecked main]
1172
1380
[stale]
1173
- [out ]
1381
+ [out2 ]
1174
1382
tmp/main.py:3: error: Revealed type is 'Any'
1175
1383
1176
1384
[case testIncrementalSilentImportsWithInnerImportsAndNewFile]
@@ -1198,7 +1406,7 @@ def test() -> str: return "foo"
1198
1406
1199
1407
[rechecked main, foo, unrelated]
1200
1408
[stale foo, unrelated]
1201
- [out ]
1409
+ [out2 ]
1202
1410
tmp/main.py:3: error: Revealed type is 'builtins.str'
1203
1411
1204
1412
[case testIncrementalWorksWithNestedClasses]
@@ -1213,4 +1421,3 @@ class MyClass:
1213
1421
1214
1422
[rechecked]
1215
1423
[stale]
1216
- [out]
0 commit comments