@@ -968,6 +968,7 @@ fn implement_py_formatting(
968968 names : & [ "__str__" ] ,
969969 arguments : Vec :: new ( ) ,
970970 returns : parse_quote ! { :: std:: string:: String } ,
971+ is_returning_not_implemented_on_extraction_error : false ,
971972 } ,
972973 ctx,
973974 )
@@ -1057,6 +1058,7 @@ fn impl_simple_enum(
10571058 names : & [ "__repr__" ] ,
10581059 arguments : Vec :: new ( ) ,
10591060 returns : parse_quote ! { & ' static str } ,
1061+ is_returning_not_implemented_on_extraction_error : false ,
10601062 } ,
10611063 ctx,
10621064 ) ?;
@@ -1090,6 +1092,7 @@ fn impl_simple_enum(
10901092 names : & [ "__int__" ] ,
10911093 arguments : Vec :: new ( ) ,
10921094 returns : parse_quote ! ( #repr_type) ,
1095+ is_returning_not_implemented_on_extraction_error : false ,
10931096 } ,
10941097 ctx,
10951098 ) ?;
@@ -1609,6 +1612,7 @@ fn impl_complex_enum_tuple_variant_len(
16091612 names : & [ "__len__" ] ,
16101613 arguments : Vec :: new ( ) ,
16111614 returns : parse_quote ! { :: std:: primitive:: usize } ,
1615+ is_returning_not_implemented_on_extraction_error : false ,
16121616 } ,
16131617 ctx,
16141618 ) ?;
@@ -1658,6 +1662,7 @@ fn impl_complex_enum_tuple_variant_getitem(
16581662 annotation: None ,
16591663 } ) ] ,
16601664 returns : parse_quote ! { #pyo3_path:: Py <#pyo3_path:: PyAny > } , // TODO: figure out correct type
1665+ is_returning_not_implemented_on_extraction_error : false ,
16611666 } ,
16621667 ctx,
16631668 ) ?;
@@ -1779,6 +1784,7 @@ fn impl_complex_enum_variant_qualname(
17791784struct FunctionIntrospectionData < ' a > {
17801785 names : & ' a [ & ' a str ] ,
17811786 arguments : Vec < FnArg < ' a > > ,
1787+ is_returning_not_implemented_on_extraction_error : bool ,
17821788 returns : syn:: Type ,
17831789}
17841790
@@ -1799,6 +1805,7 @@ impl FunctionIntrospectionData<'_> {
17991805 parse_quote ! ( -> #returns) ,
18001806 [ ] ,
18011807 false ,
1808+ self . is_returning_not_implemented_on_extraction_error ,
18021809 None ,
18031810 Some ( cls) ,
18041811 )
@@ -2043,6 +2050,7 @@ fn complex_enum_struct_variant_new<'a>(
20432050 & spec,
20442051 & [ ] ,
20452052 & variant_cls_type,
2053+ false ,
20462054 ctx,
20472055 ) ) ;
20482056 Ok ( def)
@@ -2107,6 +2115,7 @@ fn complex_enum_tuple_variant_new<'a>(
21072115 & spec,
21082116 & [ ] ,
21092117 & variant_cls_type,
2118+ false ,
21102119 ctx,
21112120 ) ) ;
21122121 Ok ( def)
@@ -2151,6 +2160,7 @@ fn complex_enum_variant_field_getter(
21512160 & spec,
21522161 field_attrs,
21532162 variant_cls_type,
2163+ false ,
21542164 ctx,
21552165 ) ) ;
21562166 Ok ( getter)
@@ -2201,6 +2211,7 @@ fn descriptors_to_items(
22012211 parse_quote ! ( -> #return_type) ,
22022212 vec ! [ PyExpr :: builtin( "property" ) ] ,
22032213 false ,
2214+ false ,
22042215 utils:: get_doc ( & field. attrs , None ) . as_ref ( ) ,
22052216 Some ( & parse_quote ! ( #cls) ) ,
22062217 ) ) ;
@@ -2255,7 +2266,8 @@ fn descriptors_to_items(
22552266 "setter" ,
22562267 ) ] ,
22572268 false ,
2258- utils:: get_doc ( & field. attrs , None ) . as_ref ( ) ,
2269+ false ,
2270+ get_doc ( & field. attrs , None ) . as_ref ( ) ,
22592271 Some ( & parse_quote ! ( #cls) ) ,
22602272 ) ) ;
22612273 }
@@ -2411,27 +2423,20 @@ fn pyclass_richcmp_simple_enum(
24112423 }
24122424 } ;
24132425 #[ cfg( feature = "experimental-inspect" ) ]
2414- let never = parse_quote ! ( ! ) ; // we need to set a type, let's pick something small, it is overridden by annotation anyway
2426+ let any = parse_quote ! ( #pyo3_path :: Py <#pyo3_path :: PyAny > ) ;
24152427 #[ cfg( feature = "experimental-inspect" ) ]
24162428 let introspection = FunctionIntrospectionData {
24172429 names : & [ "__eq__" , "__ne__" ] ,
24182430 arguments : vec ! [ FnArg :: Regular ( RegularArg {
24192431 name: Cow :: Owned ( format_ident!( "other" ) ) ,
2420- ty: & never ,
2432+ ty: & any ,
24212433 from_py_with: None ,
24222434 default_value: None ,
24232435 option_wrapped_type: None ,
2424- annotation: Some (
2425- options
2426- . eq
2427- . map( |_| PyExpr :: from_type( cls. clone( ) , None ) )
2428- . into_iter( )
2429- . chain( options. eq_int. map( |_| PyExpr :: builtin( "int" ) ) )
2430- . reduce( PyExpr :: union )
2431- . expect( "At least one must be defined" ) ,
2432- ) ,
2436+ annotation: None ,
24332437 } ) ] ,
2434- returns : parse_quote ! { :: std:: primitive:: bool } ,
2438+ returns : parse_quote ! ( :: std:: primitive:: bool ) ,
2439+ is_returning_not_implemented_on_extraction_error : true ,
24352440 } ;
24362441 let richcmp_slot = if options. eq . is_some ( ) {
24372442 generate_protocol_slot (
@@ -2507,6 +2512,7 @@ fn pyclass_richcmp(
25072512 annotation: None ,
25082513 } ) ] ,
25092514 returns : parse_quote ! { :: std:: primitive:: bool } ,
2515+ is_returning_not_implemented_on_extraction_error : true ,
25102516 } ,
25112517 ctx,
25122518 ) ?;
@@ -2546,6 +2552,7 @@ fn pyclass_hash(
25462552 names : & [ "__hash__" ] ,
25472553 arguments : Vec :: new ( ) ,
25482554 returns : parse_quote ! { :: std:: primitive:: u64 } ,
2555+ is_returning_not_implemented_on_extraction_error : false ,
25492556 } ,
25502557 ctx,
25512558 ) ?;
@@ -2632,6 +2639,7 @@ fn pyclass_new_impl<'a>(
26322639 } )
26332640 . collect ( ) ,
26342641 returns : ty. clone ( ) ,
2642+ is_returning_not_implemented_on_extraction_error : false ,
26352643 } ,
26362644 ctx,
26372645 )
0 commit comments