@@ -47,7 +47,7 @@ impl Default for PyClassArgs {
47
47
freelist : None ,
48
48
name : None ,
49
49
module : None ,
50
- base : parse_quote ! { pyo3:: PyAny } ,
50
+ base : parse_quote ! { :: pyo3:: PyAny } ,
51
51
has_dict : false ,
52
52
has_weaklist : false ,
53
53
is_gc : false ,
@@ -345,22 +345,22 @@ fn impl_methods_inventory(cls: &syn::Ident) -> TokenStream {
345
345
quote ! {
346
346
#[ doc( hidden) ]
347
347
pub struct #inventory_cls {
348
- methods: Vec <pyo3:: class:: PyMethodDefType >,
348
+ methods: :: std :: vec :: Vec <:: pyo3:: class:: PyMethodDefType >,
349
349
}
350
- impl pyo3:: class:: impl_:: PyMethodsInventory for #inventory_cls {
351
- fn new( methods: Vec <pyo3:: class:: PyMethodDefType >) -> Self {
350
+ impl :: pyo3:: class:: impl_:: PyMethodsInventory for #inventory_cls {
351
+ fn new( methods: :: std :: vec :: Vec <:: pyo3:: class:: PyMethodDefType >) -> Self {
352
352
Self { methods }
353
353
}
354
- fn get( & ' static self ) -> & ' static [ pyo3:: class:: PyMethodDefType ] {
354
+ fn get( & ' static self ) -> & ' static [ :: pyo3:: class:: PyMethodDefType ] {
355
355
& self . methods
356
356
}
357
357
}
358
358
359
- impl pyo3:: class:: impl_:: HasMethodsInventory for #cls {
359
+ impl :: pyo3:: class:: impl_:: HasMethodsInventory for #cls {
360
360
type Methods = #inventory_cls;
361
361
}
362
362
363
- pyo3:: inventory:: collect!( #inventory_cls) ;
363
+ :: pyo3:: inventory:: collect!( #inventory_cls) ;
364
364
}
365
365
}
366
366
@@ -380,31 +380,31 @@ fn impl_class(
380
380
381
381
let alloc = attr. freelist . as_ref ( ) . map ( |freelist| {
382
382
quote ! {
383
- impl pyo3:: class:: impl_:: PyClassWithFreeList for #cls {
383
+ impl :: pyo3:: class:: impl_:: PyClassWithFreeList for #cls {
384
384
#[ inline]
385
- fn get_free_list( _py: pyo3:: Python <' _>) -> & mut pyo3:: impl_:: freelist:: FreeList <* mut pyo3:: ffi:: PyObject > {
386
- static mut FREELIST : * mut pyo3:: impl_:: freelist:: FreeList <* mut pyo3:: ffi:: PyObject > = 0 as * mut _;
385
+ fn get_free_list( _py: :: pyo3:: Python <' _>) -> & mut :: pyo3:: impl_:: freelist:: FreeList <* mut :: pyo3:: ffi:: PyObject > {
386
+ static mut FREELIST : * mut :: pyo3:: impl_:: freelist:: FreeList <* mut :: pyo3:: ffi:: PyObject > = 0 as * mut _;
387
387
unsafe {
388
388
if FREELIST . is_null( ) {
389
- FREELIST = Box :: into_raw( Box :: new(
390
- pyo3:: impl_:: freelist:: FreeList :: with_capacity( #freelist) ) ) ;
389
+ FREELIST = :: std :: boxed :: Box :: into_raw( :: std :: boxed :: Box :: new(
390
+ :: pyo3:: impl_:: freelist:: FreeList :: with_capacity( #freelist) ) ) ;
391
391
}
392
392
& mut * FREELIST
393
393
}
394
394
}
395
395
}
396
396
397
- impl pyo3:: class:: impl_:: PyClassAllocImpl <#cls> for pyo3:: class:: impl_:: PyClassImplCollector <#cls> {
397
+ impl :: pyo3:: class:: impl_:: PyClassAllocImpl <#cls> for :: pyo3:: class:: impl_:: PyClassImplCollector <#cls> {
398
398
#[ inline]
399
- fn alloc_impl( self ) -> Option <pyo3:: ffi:: allocfunc> {
400
- Some ( pyo3:: class:: impl_:: alloc_with_freelist:: <#cls>)
399
+ fn alloc_impl( self ) -> :: std :: option :: Option <:: pyo3:: ffi:: allocfunc> {
400
+ :: std :: option :: Option :: Some ( :: pyo3:: class:: impl_:: alloc_with_freelist:: <#cls>)
401
401
}
402
402
}
403
403
404
- impl pyo3:: class:: impl_:: PyClassFreeImpl <#cls> for pyo3:: class:: impl_:: PyClassImplCollector <#cls> {
404
+ impl :: pyo3:: class:: impl_:: PyClassFreeImpl <#cls> for :: pyo3:: class:: impl_:: PyClassImplCollector <#cls> {
405
405
#[ inline]
406
- fn free_impl( self ) -> Option <pyo3:: ffi:: freefunc> {
407
- Some ( pyo3:: class:: impl_:: free_with_freelist:: <#cls>)
406
+ fn free_impl( self ) -> :: std :: option :: Option <:: pyo3:: ffi:: freefunc> {
407
+ :: std :: option :: Option :: Some ( :: pyo3:: class:: impl_:: free_with_freelist:: <#cls>)
408
408
}
409
409
}
410
410
}
@@ -414,23 +414,23 @@ fn impl_class(
414
414
415
415
// insert space for weak ref
416
416
let weakref = if attr. has_weaklist {
417
- quote ! { pyo3:: pyclass_slots:: PyClassWeakRefSlot }
417
+ quote ! { :: pyo3:: pyclass_slots:: PyClassWeakRefSlot }
418
418
} else if attr. has_extends {
419
- quote ! { <Self :: BaseType as pyo3:: class:: impl_:: PyClassBaseType >:: WeakRef }
419
+ quote ! { <Self :: BaseType as :: pyo3:: class:: impl_:: PyClassBaseType >:: WeakRef }
420
420
} else {
421
- quote ! { pyo3:: pyclass_slots:: PyClassDummySlot }
421
+ quote ! { :: pyo3:: pyclass_slots:: PyClassDummySlot }
422
422
} ;
423
423
let dict = if attr. has_dict {
424
- quote ! { pyo3:: pyclass_slots:: PyClassDictSlot }
424
+ quote ! { :: pyo3:: pyclass_slots:: PyClassDictSlot }
425
425
} else if attr. has_extends {
426
- quote ! { <Self :: BaseType as pyo3:: class:: impl_:: PyClassBaseType >:: Dict }
426
+ quote ! { <Self :: BaseType as :: pyo3:: class:: impl_:: PyClassBaseType >:: Dict }
427
427
} else {
428
- quote ! { pyo3:: pyclass_slots:: PyClassDummySlot }
428
+ quote ! { :: pyo3:: pyclass_slots:: PyClassDummySlot }
429
429
} ;
430
430
let module = if let Some ( m) = & attr. module {
431
- quote ! { Some ( #m) }
431
+ quote ! { :: std :: option :: Option :: Some ( #m) }
432
432
} else {
433
- quote ! { None }
433
+ quote ! { :: std :: option :: Option :: None }
434
434
} ;
435
435
436
436
// Enforce at compile time that PyGCProtocol is implemented
@@ -439,9 +439,9 @@ fn impl_class(
439
439
let closure_token = syn:: Ident :: new ( & closure_name, Span :: call_site ( ) ) ;
440
440
quote ! {
441
441
fn #closure_token( ) {
442
- use pyo3:: class;
442
+ use :: pyo3:: class;
443
443
444
- fn _assert_implements_protocol<' p, T : pyo3:: class:: PyGCProtocol <' p>>( ) { }
444
+ fn _assert_implements_protocol<' p, T : :: pyo3:: class:: PyGCProtocol <' p>>( ) { }
445
445
_assert_implements_protocol:: <#cls>( ) ;
446
446
}
447
447
}
@@ -450,30 +450,33 @@ fn impl_class(
450
450
} ;
451
451
452
452
let ( impl_inventory, for_each_py_method) = match methods_type {
453
- PyClassMethodsType :: Specialization => ( None , quote ! { visitor( collector. py_methods( ) ) ; } ) ,
453
+ PyClassMethodsType :: Specialization => (
454
+ :: std:: option:: Option :: None ,
455
+ quote ! { visitor( collector. py_methods( ) ) ; } ,
456
+ ) ,
454
457
PyClassMethodsType :: Inventory => (
455
458
Some ( impl_methods_inventory ( cls) ) ,
456
459
quote ! {
457
- for inventory in pyo3:: inventory:: iter:: <<Self as pyo3:: class:: impl_:: HasMethodsInventory >:: Methods >( ) {
458
- visitor( pyo3:: class:: impl_:: PyMethodsInventory :: get( inventory) ) ;
460
+ for inventory in :: pyo3:: inventory:: iter:: <<Self as :: pyo3:: class:: impl_:: HasMethodsInventory >:: Methods >( ) {
461
+ visitor( :: pyo3:: class:: impl_:: PyMethodsInventory :: get( inventory) ) ;
459
462
}
460
463
} ,
461
464
) ,
462
465
} ;
463
466
464
467
let base = & attr. base ;
465
468
let base_nativetype = if attr. has_extends {
466
- quote ! { <Self :: BaseType as pyo3:: class:: impl_:: PyClassBaseType >:: BaseNativeType }
469
+ quote ! { <Self :: BaseType as :: pyo3:: class:: impl_:: PyClassBaseType >:: BaseNativeType }
467
470
} else {
468
- quote ! { pyo3:: PyAny }
471
+ quote ! { :: pyo3:: PyAny }
469
472
} ;
470
473
471
474
// If #cls is not extended type, we allow Self->PyObject conversion
472
475
let into_pyobject = if !attr. has_extends {
473
476
quote ! {
474
- impl pyo3:: IntoPy <pyo3:: PyObject > for #cls {
475
- fn into_py( self , py: pyo3:: Python ) -> pyo3:: PyObject {
476
- pyo3:: IntoPy :: into_py( pyo3:: Py :: new( py, self ) . unwrap( ) , py)
477
+ impl :: pyo3:: IntoPy <:: pyo3:: PyObject > for #cls {
478
+ fn into_py( self , py: :: pyo3:: Python ) -> :: pyo3:: PyObject {
479
+ :: pyo3:: IntoPy :: into_py( :: pyo3:: Py :: new( py, self ) . unwrap( ) , py)
477
480
}
478
481
}
479
482
}
@@ -482,68 +485,68 @@ fn impl_class(
482
485
} ;
483
486
484
487
let thread_checker = if attr. has_unsendable {
485
- quote ! { pyo3:: class:: impl_:: ThreadCheckerImpl <#cls> }
488
+ quote ! { :: pyo3:: class:: impl_:: ThreadCheckerImpl <#cls> }
486
489
} else if attr. has_extends {
487
490
quote ! {
488
- pyo3:: class:: impl_:: ThreadCheckerInherited <#cls, <#cls as pyo3:: class:: impl_:: PyClassImpl >:: BaseType >
491
+ :: pyo3:: class:: impl_:: ThreadCheckerInherited <#cls, <#cls as :: pyo3:: class:: impl_:: PyClassImpl >:: BaseType >
489
492
}
490
493
} else {
491
- quote ! { pyo3:: class:: impl_:: ThreadCheckerStub <#cls> }
494
+ quote ! { :: pyo3:: class:: impl_:: ThreadCheckerStub <#cls> }
492
495
} ;
493
496
494
497
let is_gc = attr. is_gc ;
495
498
let is_basetype = attr. is_basetype ;
496
499
let is_subclass = attr. has_extends ;
497
500
498
501
Ok ( quote ! {
499
- unsafe impl pyo3:: type_object:: PyTypeInfo for #cls {
500
- type AsRefTarget = pyo3:: PyCell <Self >;
502
+ unsafe impl :: pyo3:: type_object:: PyTypeInfo for #cls {
503
+ type AsRefTarget = :: pyo3:: PyCell <Self >;
501
504
502
505
const NAME : & ' static str = #cls_name;
503
- const MODULE : Option <& ' static str > = #module;
506
+ const MODULE : :: std :: option :: Option <& ' static str > = #module;
504
507
505
508
#[ inline]
506
- fn type_object_raw( py: pyo3:: Python <' _>) -> * mut pyo3:: ffi:: PyTypeObject {
509
+ fn type_object_raw( py: :: pyo3:: Python <' _>) -> * mut :: pyo3:: ffi:: PyTypeObject {
507
510
#deprecations
508
511
509
- use pyo3:: type_object:: LazyStaticType ;
512
+ use :: pyo3:: type_object:: LazyStaticType ;
510
513
static TYPE_OBJECT : LazyStaticType = LazyStaticType :: new( ) ;
511
514
TYPE_OBJECT . get_or_init:: <Self >( py)
512
515
}
513
516
}
514
517
515
- impl pyo3:: PyClass for #cls {
518
+ impl :: pyo3:: PyClass for #cls {
516
519
type Dict = #dict;
517
520
type WeakRef = #weakref;
518
521
type BaseNativeType = #base_nativetype;
519
522
}
520
523
521
- impl <' a> pyo3:: derive_utils:: ExtractExt <' a> for & ' a #cls
524
+ impl <' a> :: pyo3:: derive_utils:: ExtractExt <' a> for & ' a #cls
522
525
{
523
- type Target = pyo3:: PyRef <' a, #cls>;
526
+ type Target = :: pyo3:: PyRef <' a, #cls>;
524
527
}
525
528
526
- impl <' a> pyo3:: derive_utils:: ExtractExt <' a> for & ' a mut #cls
529
+ impl <' a> :: pyo3:: derive_utils:: ExtractExt <' a> for & ' a mut #cls
527
530
{
528
- type Target = pyo3:: PyRefMut <' a, #cls>;
531
+ type Target = :: pyo3:: PyRefMut <' a, #cls>;
529
532
}
530
533
531
534
#into_pyobject
532
535
533
536
#impl_inventory
534
537
535
- impl pyo3:: class:: impl_:: PyClassImpl for #cls {
538
+ impl :: pyo3:: class:: impl_:: PyClassImpl for #cls {
536
539
const DOC : & ' static str = #doc;
537
540
const IS_GC : bool = #is_gc;
538
541
const IS_BASETYPE : bool = #is_basetype;
539
542
const IS_SUBCLASS : bool = #is_subclass;
540
543
541
- type Layout = pyo3:: PyCell <Self >;
544
+ type Layout = :: pyo3:: PyCell <Self >;
542
545
type BaseType = #base;
543
546
type ThreadChecker = #thread_checker;
544
547
545
- fn for_each_method_def( visitor: & mut dyn FnMut ( & [ pyo3:: class:: PyMethodDefType ] ) ) {
546
- use pyo3:: class:: impl_:: * ;
548
+ fn for_each_method_def( visitor: & mut dyn :: std :: ops :: FnMut ( & [ :: pyo3:: class:: PyMethodDefType ] ) ) {
549
+ use :: pyo3:: class:: impl_:: * ;
547
550
let collector = PyClassImplCollector :: <Self >:: new( ) ;
548
551
#for_each_py_method;
549
552
visitor( collector. py_class_descriptors( ) ) ;
@@ -554,30 +557,30 @@ fn impl_class(
554
557
visitor( collector. mapping_protocol_methods( ) ) ;
555
558
visitor( collector. number_protocol_methods( ) ) ;
556
559
}
557
- fn get_new( ) -> Option <pyo3:: ffi:: newfunc> {
558
- use pyo3:: class:: impl_:: * ;
560
+ fn get_new( ) -> :: std :: option :: Option <:: pyo3:: ffi:: newfunc> {
561
+ use :: pyo3:: class:: impl_:: * ;
559
562
let collector = PyClassImplCollector :: <Self >:: new( ) ;
560
563
collector. new_impl( )
561
564
}
562
- fn get_alloc( ) -> Option <pyo3:: ffi:: allocfunc> {
563
- use pyo3:: class:: impl_:: * ;
565
+ fn get_alloc( ) -> :: std :: option :: Option <:: pyo3:: ffi:: allocfunc> {
566
+ use :: pyo3:: class:: impl_:: * ;
564
567
let collector = PyClassImplCollector :: <Self >:: new( ) ;
565
568
collector. alloc_impl( )
566
569
}
567
- fn get_free( ) -> Option <pyo3:: ffi:: freefunc> {
568
- use pyo3:: class:: impl_:: * ;
570
+ fn get_free( ) -> :: std :: option :: Option <:: pyo3:: ffi:: freefunc> {
571
+ use :: pyo3:: class:: impl_:: * ;
569
572
let collector = PyClassImplCollector :: <Self >:: new( ) ;
570
573
collector. free_impl( )
571
574
}
572
- fn get_call( ) -> Option <pyo3:: ffi:: PyCFunctionWithKeywords > {
573
- use pyo3:: class:: impl_:: * ;
575
+ fn get_call( ) -> :: std :: option :: Option <:: pyo3:: ffi:: PyCFunctionWithKeywords > {
576
+ use :: pyo3:: class:: impl_:: * ;
574
577
let collector = PyClassImplCollector :: <Self >:: new( ) ;
575
578
collector. call_impl( )
576
579
}
577
580
578
- fn for_each_proto_slot( visitor: & mut dyn FnMut ( & [ pyo3:: ffi:: PyType_Slot ] ) ) {
581
+ fn for_each_proto_slot( visitor: & mut dyn :: std :: ops :: FnMut ( & [ :: pyo3:: ffi:: PyType_Slot ] ) ) {
579
582
// Implementation which uses dtolnay specialization to load all slots.
580
- use pyo3:: class:: impl_:: * ;
583
+ use :: pyo3:: class:: impl_:: * ;
581
584
let collector = PyClassImplCollector :: <Self >:: new( ) ;
582
585
visitor( collector. object_protocol_slots( ) ) ;
583
586
visitor( collector. number_protocol_slots( ) ) ;
@@ -590,8 +593,8 @@ fn impl_class(
590
593
visitor( collector. buffer_protocol_slots( ) ) ;
591
594
}
592
595
593
- fn get_buffer( ) -> Option <& ' static pyo3:: class:: impl_:: PyBufferProcs > {
594
- use pyo3:: class:: impl_:: * ;
596
+ fn get_buffer( ) -> :: std :: option :: Option <& ' static :: pyo3:: class:: impl_:: PyBufferProcs > {
597
+ use :: pyo3:: class:: impl_:: * ;
595
598
let collector = PyClassImplCollector :: <Self >:: new( ) ;
596
599
collector. buffer_procs( )
597
600
}
@@ -645,11 +648,11 @@ fn impl_descriptors(
645
648
. collect :: < syn:: Result < _ > > ( ) ?;
646
649
647
650
Ok ( quote ! {
648
- impl pyo3:: class:: impl_:: PyClassDescriptors <#cls>
649
- for pyo3:: class:: impl_:: PyClassImplCollector <#cls>
651
+ impl :: pyo3:: class:: impl_:: PyClassDescriptors <#cls>
652
+ for :: pyo3:: class:: impl_:: PyClassImplCollector <#cls>
650
653
{
651
- fn py_class_descriptors( self ) -> & ' static [ pyo3:: class:: methods:: PyMethodDefType ] {
652
- static METHODS : & [ pyo3:: class:: methods:: PyMethodDefType ] = & [ #( #py_methods) , * ] ;
654
+ fn py_class_descriptors( self ) -> & ' static [ :: pyo3:: class:: methods:: PyMethodDefType ] {
655
+ static METHODS : & [ :: pyo3:: class:: methods:: PyMethodDefType ] = & [ #( #py_methods) , * ] ;
653
656
METHODS
654
657
}
655
658
}
0 commit comments