@@ -38,6 +38,7 @@ use crate::types::{
3838 ManualPEP695TypeAliasType , MaterializationKind , NormalizedVisitor , PropertyInstanceType ,
3939 StringLiteralType , TypeAliasType , TypeContext , TypeMapping , TypeRelation , TypedDictParams ,
4040 UnionBuilder , VarianceInferable , binding_type, declaration_type, determine_upper_bound,
41+ todo_type,
4142} ;
4243use crate :: {
4344 Db , FxIndexMap , FxIndexSet , FxOrderSet , Program ,
@@ -1664,20 +1665,28 @@ impl<'db> ClassLiteral<'db> {
16641665 let class_definition =
16651666 semantic_index ( db, self . file ( db) ) . expect_single_definition ( class_stmt) ;
16661667
1667- if self . is_known ( db , KnownClass :: VersionInfo ) {
1668- let tuple_type = TupleType :: new ( db , & TupleSpec :: version_info_spec ( db ) )
1669- . expect ( "sys.version_info tuple spec should always be a valid tuple" ) ;
1668+ if class_stmt . bases ( ) . iter ( ) . any ( ast :: Expr :: is_starred_expr ) {
1669+ return Box :: new ( [ todo_type ! ( "Starred expressions in class bases" ) ] ) ;
1670+ }
16701671
1671- Box :: new ( [
1672- definition_expression_type ( db, class_definition, & class_stmt. bases ( ) [ 0 ] ) ,
1673- Type :: from ( tuple_type. to_class_type ( db) ) ,
1674- ] )
1675- } else {
1676- class_stmt
1672+ match self . known ( db) {
1673+ Some ( KnownClass :: VersionInfo ) => {
1674+ let tuple_type = TupleType :: new ( db, & TupleSpec :: version_info_spec ( db) )
1675+ . expect ( "sys.version_info tuple spec should always be a valid tuple" ) ;
1676+
1677+ Box :: new ( [
1678+ definition_expression_type ( db, class_definition, & class_stmt. bases ( ) [ 0 ] ) ,
1679+ Type :: from ( tuple_type. to_class_type ( db) ) ,
1680+ ] )
1681+ }
1682+ // Special-case `NotImplementedType`: typeshed says that it inherits from `Any`,
1683+ // but this causes more problems than it fixes.
1684+ Some ( KnownClass :: NotImplementedType ) => Box :: new ( [ ] ) ,
1685+ _ => class_stmt
16771686 . bases ( )
16781687 . iter ( )
16791688 . map ( |base_node| definition_expression_type ( db, class_definition, base_node) )
1680- . collect ( )
1689+ . collect ( ) ,
16811690 }
16821691 }
16831692
0 commit comments