@@ -38,7 +38,7 @@ use crate::types::{
3838 ManualPEP695TypeAliasType , MaterializationKind , NormalizedVisitor , PropertyInstanceType ,
3939 StringLiteralType , TypeAliasType , TypeContext , TypeMapping , TypeRelation , TypedDictParams ,
4040 UnionBuilder , VarianceInferable , declaration_type, determine_upper_bound,
41- exceeds_max_specialization_depth, infer_definition_types,
41+ exceeds_max_specialization_depth, infer_definition_types, todo_type ,
4242} ;
4343use crate :: {
4444 Db , FxIndexMap , FxIndexSet , FxOrderSet , Program ,
@@ -1598,20 +1598,28 @@ impl<'db> ClassLiteral<'db> {
15981598 let class_definition =
15991599 semantic_index ( db, self . file ( db) ) . expect_single_definition ( class_stmt) ;
16001600
1601- if self . is_known ( db , KnownClass :: VersionInfo ) {
1602- let tuple_type = TupleType :: new ( db , & TupleSpec :: version_info_spec ( db ) )
1603- . expect ( "sys.version_info tuple spec should always be a valid tuple" ) ;
1601+ if class_stmt . bases ( ) . iter ( ) . any ( ast :: Expr :: is_starred_expr ) {
1602+ return Box :: new ( [ todo_type ! ( "Starred expressions in class bases" ) ] ) ;
1603+ }
16041604
1605- Box :: new ( [
1606- definition_expression_type ( db, class_definition, & class_stmt. bases ( ) [ 0 ] ) ,
1607- Type :: from ( tuple_type. to_class_type ( db) ) ,
1608- ] )
1609- } else {
1610- class_stmt
1605+ match self . known ( db) {
1606+ Some ( KnownClass :: VersionInfo ) => {
1607+ let tuple_type = TupleType :: new ( db, & TupleSpec :: version_info_spec ( db) )
1608+ . expect ( "sys.version_info tuple spec should always be a valid tuple" ) ;
1609+
1610+ Box :: new ( [
1611+ definition_expression_type ( db, class_definition, & class_stmt. bases ( ) [ 0 ] ) ,
1612+ Type :: from ( tuple_type. to_class_type ( db) ) ,
1613+ ] )
1614+ }
1615+ // Special-case `NotImplementedType`: typeshed says that it inherits from `Any`,
1616+ // but this causes more problems than it fixes.
1617+ Some ( KnownClass :: NotImplementedType ) => Box :: new ( [ ] ) ,
1618+ _ => class_stmt
16111619 . bases ( )
16121620 . iter ( )
16131621 . map ( |base_node| definition_expression_type ( db, class_definition, base_node) )
1614- . collect ( )
1622+ . collect ( ) ,
16151623 }
16161624 }
16171625
0 commit comments