File tree 3 files changed +37
-6
lines changed
3 files changed +37
-6
lines changed Original file line number Diff line number Diff line change @@ -304,23 +304,22 @@ def snapshot_definition(node: Optional[SymbolNode],
304
304
snapshot_optional_type (node .var .type ),
305
305
snapshot_definition (node .func , common ))
306
306
elif isinstance (node , TypeInfo ):
307
- # TODO:
308
- # type_vars
309
- # bases
310
- # _promote
311
307
attrs = (node .is_abstract ,
312
308
node .is_enum ,
313
309
node .fallback_to_any ,
314
310
node .is_named_tuple ,
315
311
node .is_newtype ,
316
312
snapshot_optional_type (node .tuple_type ),
317
313
snapshot_optional_type (node .typeddict_type ),
318
- [base .fullname () for base in node .mro ])
314
+ [base .fullname () for base in node .mro ],
315
+ node .type_vars ,
316
+ [snapshot_type (base ) for base in node .bases ],
317
+ snapshot_optional_type (node ._promote ))
319
318
prefix = node .fullname ()
320
319
symbol_table = snapshot_symbol_table (prefix , node .names )
321
320
return ('TypeInfo' , common , attrs , symbol_table )
322
321
else :
323
- # TODO: Handle additional types: TypeVarExpr, MypyFile, .. .
322
+ # Other node types are handled elsewhere .
324
323
assert False , type (node )
325
324
326
325
Original file line number Diff line number Diff line change @@ -680,3 +680,13 @@ B = Dict[str, S]
680
680
[out]
681
681
__main__.A
682
682
__main__.T
683
+
684
+ [case testChangeGenericBaseClassOnly]
685
+ from typing import List
686
+ class C(List[int]): pass
687
+ [file next.py]
688
+ from typing import List
689
+ class C(List[str]): pass
690
+ [builtins fixtures/list.pyi]
691
+ [out]
692
+ __main__.C
Original file line number Diff line number Diff line change @@ -1297,6 +1297,28 @@ class A: pass
1297
1297
main:2: error: Module 'a' has no attribute 'A'
1298
1298
==
1299
1299
1300
+ [case testRefreshGenericAndFailInPass3]
1301
+ # Failure in semantic analysis pass 3
1302
+ from a import C
1303
+ a: C[int]
1304
+ [file a.py]
1305
+ from typing import TypeVar, Generic
1306
+ T = TypeVar('T')
1307
+ class C(Generic[T]): pass
1308
+ [file a.py.2]
1309
+ from typing import TypeVar, Generic
1310
+ T = TypeVar('T')
1311
+ S = TypeVar('S')
1312
+ class C(Generic[T, S]): pass
1313
+ [file a.py.3]
1314
+ from typing import TypeVar, Generic
1315
+ T = TypeVar('T')
1316
+ class C(Generic[T]): pass
1317
+ [out]
1318
+ ==
1319
+ main:3: error: "C" expects 2 type arguments, but 1 given
1320
+ ==
1321
+
1300
1322
[case testPrintStatement_python2]
1301
1323
# flags: --py2
1302
1324
import a
You can’t perform that action at this time.
0 commit comments