@@ -20,7 +20,7 @@ use std::hash::{Hash, Hasher};
2020use  std:: mem:: take; 
2121use  std:: sync:: atomic:: { AtomicUsize ,  Ordering } ; 
2222use  syn:: visit_mut:: { visit_type_mut,  VisitMut } ; 
23- use  syn:: { Attribute ,  Ident ,  ReturnType ,  Type ,  TypePath } ; 
23+ use  syn:: { Attribute ,  Ident ,  Path ,   ReturnType ,  Type ,  TypePath } ; 
2424
2525static  GLOBAL_COUNTER_FOR_UNIQUE_NAMES :  AtomicUsize  = AtomicUsize :: new ( 0 ) ; 
2626
@@ -61,19 +61,23 @@ pub fn class_introspection_code(
6161    pyo3_crate_path :  & PyO3CratePath , 
6262    ident :  & Ident , 
6363    name :  & str , 
64+     extends :  Option < & Path > , 
6465)  -> TokenStream  { 
65-     IntrospectionNode :: Map ( 
66-         [ 
67-             ( "type" ,  IntrospectionNode :: String ( "class" . into ( ) ) ) , 
68-             ( 
69-                 "id" , 
70-                 IntrospectionNode :: IntrospectionId ( Some ( ident_to_type ( ident) ) ) , 
71-             ) , 
72-             ( "name" ,  IntrospectionNode :: String ( name. into ( ) ) ) , 
73-         ] 
74-         . into ( ) , 
75-     ) 
76-     . emit ( pyo3_crate_path) 
66+     let  mut  desc = HashMap :: from ( [ 
67+         ( "type" ,  IntrospectionNode :: String ( "class" . into ( ) ) ) , 
68+         ( 
69+             "id" , 
70+             IntrospectionNode :: IntrospectionId ( Some ( ident_to_type ( ident) ) ) , 
71+         ) , 
72+         ( "name" ,  IntrospectionNode :: String ( name. into ( ) ) ) , 
73+     ] ) ; 
74+     if  let  Some ( extends)  = extends { 
75+         desc. insert ( 
76+             "bases" , 
77+             IntrospectionNode :: List ( vec ! [ IntrospectionNode :: BaseType ( extends) . into( ) ] ) , 
78+         ) ; 
79+     } 
80+     IntrospectionNode :: Map ( desc) . emit ( pyo3_crate_path) 
7781} 
7882
7983#[ allow( clippy:: too_many_arguments) ]  
@@ -345,6 +349,7 @@ enum IntrospectionNode<'a> {
345349    IntrospectionId ( Option < Cow < ' a ,  Type > > ) , 
346350    InputType  {  rust_type :  Type ,  nullable :  bool  } , 
347351    OutputType  {  rust_type :  Type ,  is_final :  bool  } , 
352+     BaseType ( & ' a  Path ) , 
348353    Map ( HashMap < & ' static  str ,  IntrospectionNode < ' a > > ) , 
349354    List ( Vec < AttributedIntrospectionNode < ' a > > ) , 
350355} 
@@ -410,6 +415,13 @@ impl IntrospectionNode<'_> {
410415                } 
411416                content. push_str ( "\" " ) ; 
412417            } 
418+             Self :: BaseType ( path)  => { 
419+                 content. push_str ( "\" " ) ; 
420+                 content. push_tokens ( 
421+                     quote !  {  <#path as  #pyo3_crate_path:: impl_:: pyclass:: PyClassBaseType >:: BASE_NAME . as_bytes( )  } , 
422+                 ) ; 
423+                 content. push_str ( "\" " ) ; 
424+             } 
413425            Self :: Map ( map)  => { 
414426                content. push_str ( "{" ) ; 
415427                for  ( i,  ( key,  value) )  in  map. into_iter ( ) . enumerate ( )  { 
0 commit comments