66
66
ScopedInjectable ,
67
67
ScopedSlotInjectable ,
68
68
ShouldBeInjectable ,
69
- SimpleInjectable ,
70
69
SimpleScopedInjectable ,
71
70
SingletonInjectable ,
71
+ TransientInjectable ,
72
72
)
73
73
from injection ._core .slots import SlotKey
74
74
from injection .exceptions import (
@@ -430,7 +430,7 @@ def injectable[**P, T](
430
430
wrapped : Recipe [P , T ] | None = None ,
431
431
/ ,
432
432
* ,
433
- cls : InjectableFactory [T ] = SimpleInjectable ,
433
+ cls : InjectableFactory [T ] = TransientInjectable ,
434
434
ignore_type_hint : bool = False ,
435
435
inject : bool = True ,
436
436
on : TypeInfo [T ] = (),
@@ -583,7 +583,12 @@ def make_injected_function[**P, T](
583
583
threadsafe : bool = ...,
584
584
) -> AsyncInjectedFunction [P , T ]: ...
585
585
586
- def make_injected_function (self , wrapped , / , threadsafe = False ): # type: ignore[no-untyped-def]
586
+ def make_injected_function [** P , T ](
587
+ self ,
588
+ wrapped : Callable [P , T ],
589
+ / ,
590
+ threadsafe : bool = False ,
591
+ ) -> InjectedFunction [P , T ]:
587
592
metadata = InjectMetadata (wrapped , threadsafe )
588
593
589
594
@metadata .task
@@ -592,7 +597,7 @@ def listen() -> None:
592
597
self .add_listener (metadata )
593
598
594
599
if iscoroutinefunction (wrapped ):
595
- return AsyncInjectedFunction (metadata )
600
+ return AsyncInjectedFunction (metadata ) # type: ignore[arg-type, return-value]
596
601
597
602
return SyncInjectedFunction (metadata )
598
603
@@ -630,7 +635,11 @@ async def aget_instance[T](
630
635
default : None = ...,
631
636
) -> T | None : ...
632
637
633
- async def aget_instance (self , cls , default = None ): # type: ignore[no-untyped-def]
638
+ async def aget_instance [T , Default ](
639
+ self ,
640
+ cls : InputType [T ],
641
+ default : Default | None = None ,
642
+ ) -> T | Default | None :
634
643
try :
635
644
return await self .afind_instance (cls )
636
645
except (KeyError , SkipInjectable ):
@@ -650,7 +659,11 @@ def get_instance[T](
650
659
default : None = ...,
651
660
) -> T | None : ...
652
661
653
- def get_instance (self , cls , default = None ): # type: ignore[no-untyped-def]
662
+ def get_instance [T , Default ](
663
+ self ,
664
+ cls : InputType [T ],
665
+ default : Default | None = None ,
666
+ ) -> T | Default | None :
654
667
try :
655
668
return self .find_instance (cls )
656
669
except (KeyError , SkipInjectable ):
@@ -674,7 +687,13 @@ def aget_lazy_instance[T](
674
687
cache : bool = ...,
675
688
) -> Awaitable [T | None ]: ...
676
689
677
- def aget_lazy_instance (self , cls , default = None , * , cache = False ): # type: ignore[no-untyped-def]
690
+ def aget_lazy_instance [T , Default ](
691
+ self ,
692
+ cls : InputType [T ],
693
+ default : Default | None = None ,
694
+ * ,
695
+ cache : bool = False ,
696
+ ) -> Awaitable [T | Default | None ]:
678
697
if cache :
679
698
return alazy (lambda : self .aget_instance (cls , default ))
680
699
@@ -700,7 +719,13 @@ def get_lazy_instance[T](
700
719
cache : bool = ...,
701
720
) -> Invertible [T | None ]: ...
702
721
703
- def get_lazy_instance (self , cls , default = None , * , cache = False ): # type: ignore[no-untyped-def]
722
+ def get_lazy_instance [T , Default ](
723
+ self ,
724
+ cls : InputType [T ],
725
+ default : Default | None = None ,
726
+ * ,
727
+ cache : bool = False ,
728
+ ) -> Invertible [T | Default | None ]:
704
729
if cache :
705
730
return lazy (lambda : self .get_instance (cls , default ))
706
731
@@ -790,8 +815,6 @@ def load_profile(self, *names: str) -> ContextManager[Self]:
790
815
791
816
self .unlock ().init_modules (* modules )
792
817
793
- del module , modules
794
-
795
818
@contextmanager
796
819
def cleaner () -> Iterator [Self ]:
797
820
yield self
0 commit comments