@@ -560,7 +560,7 @@ def inject[**P, T](
560560 wrapped : Callable [P , T ] | None = None ,
561561 / ,
562562 * ,
563- threadsafe : bool = False ,
563+ threadsafe : bool | None = None ,
564564 ) -> Any :
565565 def decorator (wp : Callable [P , T ]) -> Callable [P , T ]:
566566 if isclass (wp ):
@@ -576,22 +576,22 @@ def make_injected_function[**P, T](
576576 self ,
577577 wrapped : Callable [P , T ],
578578 / ,
579- threadsafe : bool = ...,
579+ threadsafe : bool | None = ...,
580580 ) -> SyncInjectedFunction [P , T ]: ...
581581
582582 @overload
583583 def make_injected_function [** P , T ](
584584 self ,
585585 wrapped : Callable [P , Awaitable [T ]],
586586 / ,
587- threadsafe : bool = ...,
587+ threadsafe : bool | None = ...,
588588 ) -> AsyncInjectedFunction [P , T ]: ...
589589
590590 def make_injected_function [** P , T ](
591591 self ,
592592 wrapped : Callable [P , T ],
593593 / ,
594- threadsafe : bool = False ,
594+ threadsafe : bool | None = None ,
595595 ) -> InjectedFunction [P , T ]:
596596 metadata = InjectMetadata (wrapped , threadsafe )
597597
@@ -609,7 +609,7 @@ def make_async_factory[T](
609609 self ,
610610 wrapped : type [T ],
611611 / ,
612- threadsafe : bool = False ,
612+ threadsafe : bool | None = None ,
613613 ) -> Callable [..., Awaitable [T ]]:
614614 factory : InjectedFunction [..., T ] = self .make_injected_function (
615615 wrapped ,
@@ -621,13 +621,18 @@ async def afind_instance[T](
621621 self ,
622622 cls : InputType [T ],
623623 * ,
624- threadsafe : bool = False ,
624+ threadsafe : bool | None = None ,
625625 ) -> T :
626626 with get_lock (threadsafe ):
627627 injectable = self [cls ]
628628 return await injectable .aget_instance ()
629629
630- def find_instance [T ](self , cls : InputType [T ], * , threadsafe : bool = False ) -> T :
630+ def find_instance [T ](
631+ self ,
632+ cls : InputType [T ],
633+ * ,
634+ threadsafe : bool | None = None ,
635+ ) -> T :
631636 with get_lock (threadsafe ):
632637 injectable = self [cls ]
633638 return injectable .get_instance ()
@@ -638,7 +643,7 @@ async def aget_instance[T, Default](
638643 cls : InputType [T ],
639644 default : Default ,
640645 * ,
641- threadsafe : bool = ...,
646+ threadsafe : bool | None = ...,
642647 ) -> T | Default : ...
643648
644649 @overload
@@ -647,15 +652,15 @@ async def aget_instance[T](
647652 cls : InputType [T ],
648653 default : T = ...,
649654 * ,
650- threadsafe : bool = ...,
655+ threadsafe : bool | None = ...,
651656 ) -> T : ...
652657
653658 async def aget_instance [T , Default ](
654659 self ,
655660 cls : InputType [T ],
656661 default : Default = NotImplemented ,
657662 * ,
658- threadsafe : bool = False ,
663+ threadsafe : bool | None = None ,
659664 ) -> T | Default :
660665 try :
661666 return await self .afind_instance (cls , threadsafe = threadsafe )
@@ -668,7 +673,7 @@ def get_instance[T, Default](
668673 cls : InputType [T ],
669674 default : Default ,
670675 * ,
671- threadsafe : bool = ...,
676+ threadsafe : bool | None = ...,
672677 ) -> T | Default : ...
673678
674679 @overload
@@ -677,15 +682,15 @@ def get_instance[T](
677682 cls : InputType [T ],
678683 default : T = ...,
679684 * ,
680- threadsafe : bool = ...,
685+ threadsafe : bool | None = ...,
681686 ) -> T : ...
682687
683688 def get_instance [T , Default ](
684689 self ,
685690 cls : InputType [T ],
686691 default : Default = NotImplemented ,
687692 * ,
688- threadsafe : bool = False ,
693+ threadsafe : bool | None = None ,
689694 ) -> T | Default :
690695 try :
691696 return self .find_instance (cls , threadsafe = threadsafe )
@@ -698,7 +703,7 @@ def aget_lazy_instance[T, Default](
698703 cls : InputType [T ],
699704 default : Default ,
700705 * ,
701- threadsafe : bool = ...,
706+ threadsafe : bool | None = ...,
702707 ) -> Awaitable [T | Default ]: ...
703708
704709 @overload
@@ -707,15 +712,15 @@ def aget_lazy_instance[T](
707712 cls : InputType [T ],
708713 default : T = ...,
709714 * ,
710- threadsafe : bool = ...,
715+ threadsafe : bool | None = ...,
711716 ) -> Awaitable [T ]: ...
712717
713718 def aget_lazy_instance [T , Default ](
714719 self ,
715720 cls : InputType [T ],
716721 default : Default = NotImplemented ,
717722 * ,
718- threadsafe : bool = False ,
723+ threadsafe : bool | None = None ,
719724 ) -> Awaitable [T | Default ]:
720725 function = self .make_injected_function (
721726 lambda instance = default : instance ,
@@ -730,7 +735,7 @@ def get_lazy_instance[T, Default](
730735 cls : InputType [T ],
731736 default : Default ,
732737 * ,
733- threadsafe : bool = ...,
738+ threadsafe : bool | None = ...,
734739 ) -> Invertible [T | Default ]: ...
735740
736741 @overload
@@ -739,15 +744,15 @@ def get_lazy_instance[T](
739744 cls : InputType [T ],
740745 default : T = ...,
741746 * ,
742- threadsafe : bool = ...,
747+ threadsafe : bool | None = ...,
743748 ) -> Invertible [T ]: ...
744749
745750 def get_lazy_instance [T , Default ](
746751 self ,
747752 cls : InputType [T ],
748753 default : Default = NotImplemented ,
749754 * ,
750- threadsafe : bool = False ,
755+ threadsafe : bool | None = None ,
751756 ) -> Invertible [T | Default ]:
752757 function = self .make_injected_function (
753758 lambda instance = default : instance ,
@@ -1013,7 +1018,12 @@ class InjectMetadata[**P, T](Caller[P, T], EventListener):
10131018 __tasks : deque [Callable [..., Any ]]
10141019 __wrapped : Callable [P , T ]
10151020
1016- def __init__ (self , wrapped : Callable [P , T ], / , threadsafe : bool ) -> None :
1021+ def __init__ (
1022+ self ,
1023+ wrapped : Callable [P , T ],
1024+ / ,
1025+ threadsafe : bool | None = None ,
1026+ ) -> None :
10171027 self .__dependencies = Dependencies .empty ()
10181028 self .__lock = get_lock (threadsafe )
10191029 self .__owner = None
0 commit comments