2929from logging import Logger , getLogger
3030from types import MethodType
3131from typing import (
32+ TYPE_CHECKING ,
3233 Any ,
3334 AsyncContextManager ,
3435 ClassVar ,
@@ -577,21 +578,23 @@ def decorator(wp: Callable[P, T]) -> Callable[P, T]:
577578
578579 return decorator (wrapped ) if wrapped else decorator
579580
580- @overload
581- def make_injected_function [** P , T ](
582- self ,
583- wrapped : Callable [P , T ],
584- / ,
585- threadsafe : bool | None = ...,
586- ) -> SyncInjectedFunction [P , T ]: ...
581+ if TYPE_CHECKING : # pragma: no cover
587582
588- @overload
589- def make_injected_function [** P , T ](
590- self ,
591- wrapped : Callable [P , Awaitable [T ]],
592- / ,
593- threadsafe : bool | None = ...,
594- ) -> AsyncInjectedFunction [P , T ]: ...
583+ @overload
584+ def make_injected_function [** P , T ](
585+ self ,
586+ wrapped : Callable [P , T ],
587+ / ,
588+ threadsafe : bool | None = ...,
589+ ) -> SyncInjectedFunction [P , T ]: ...
590+
591+ @overload
592+ def make_injected_function [** P , T ](
593+ self ,
594+ wrapped : Callable [P , Awaitable [T ]],
595+ / ,
596+ threadsafe : bool | None = ...,
597+ ) -> AsyncInjectedFunction [P , T ]: ...
595598
596599 def make_injected_function [** P , T ](
597600 self ,
@@ -643,23 +646,25 @@ def find_instance[T](
643646 injectable = self [cls ]
644647 return injectable .get_instance ()
645648
646- @overload
647- async def aget_instance [T , Default ](
648- self ,
649- cls : InputType [T ],
650- default : Default ,
651- * ,
652- threadsafe : bool | None = ...,
653- ) -> T | Default : ...
654-
655- @overload
656- async def aget_instance [T ](
657- self ,
658- cls : InputType [T ],
659- default : T = ...,
660- * ,
661- threadsafe : bool | None = ...,
662- ) -> T : ...
649+ if TYPE_CHECKING : # pragma: no cover
650+
651+ @overload
652+ async def aget_instance [T , Default ](
653+ self ,
654+ cls : InputType [T ],
655+ default : Default ,
656+ * ,
657+ threadsafe : bool | None = ...,
658+ ) -> T | Default : ...
659+
660+ @overload
661+ async def aget_instance [T ](
662+ self ,
663+ cls : InputType [T ],
664+ default : T = ...,
665+ * ,
666+ threadsafe : bool | None = ...,
667+ ) -> T : ...
663668
664669 async def aget_instance [T , Default ](
665670 self ,
@@ -673,23 +678,25 @@ async def aget_instance[T, Default](
673678 except (KeyError , SkipInjectable ):
674679 return default
675680
676- @overload
677- def get_instance [T , Default ](
678- self ,
679- cls : InputType [T ],
680- default : Default ,
681- * ,
682- threadsafe : bool | None = ...,
683- ) -> T | Default : ...
684-
685- @overload
686- def get_instance [T ](
687- self ,
688- cls : InputType [T ],
689- default : T = ...,
690- * ,
691- threadsafe : bool | None = ...,
692- ) -> T : ...
681+ if TYPE_CHECKING : # pragma: no cover
682+
683+ @overload
684+ def get_instance [T , Default ](
685+ self ,
686+ cls : InputType [T ],
687+ default : Default ,
688+ * ,
689+ threadsafe : bool | None = ...,
690+ ) -> T | Default : ...
691+
692+ @overload
693+ def get_instance [T ](
694+ self ,
695+ cls : InputType [T ],
696+ default : T = ...,
697+ * ,
698+ threadsafe : bool | None = ...,
699+ ) -> T : ...
693700
694701 def get_instance [T , Default ](
695702 self ,
@@ -703,23 +710,25 @@ def get_instance[T, Default](
703710 except (KeyError , SkipInjectable ):
704711 return default
705712
706- @overload
707- def aget_lazy_instance [T , Default ](
708- self ,
709- cls : InputType [T ],
710- default : Default ,
711- * ,
712- threadsafe : bool | None = ...,
713- ) -> Awaitable [T | Default ]: ...
714-
715- @overload
716- def aget_lazy_instance [T ](
717- self ,
718- cls : InputType [T ],
719- default : T = ...,
720- * ,
721- threadsafe : bool | None = ...,
722- ) -> Awaitable [T ]: ...
713+ if TYPE_CHECKING : # pragma: no cover
714+
715+ @overload
716+ def aget_lazy_instance [T , Default ](
717+ self ,
718+ cls : InputType [T ],
719+ default : Default ,
720+ * ,
721+ threadsafe : bool | None = ...,
722+ ) -> Awaitable [T | Default ]: ...
723+
724+ @overload
725+ def aget_lazy_instance [T ](
726+ self ,
727+ cls : InputType [T ],
728+ default : T = ...,
729+ * ,
730+ threadsafe : bool | None = ...,
731+ ) -> Awaitable [T ]: ...
723732
724733 def aget_lazy_instance [T , Default ](
725734 self ,
@@ -735,23 +744,25 @@ def aget_lazy_instance[T, Default](
735744 metadata = function .__inject_metadata__ .set_owner (cls )
736745 return SimpleAwaitable (metadata .acall )
737746
738- @overload
739- def get_lazy_instance [T , Default ](
740- self ,
741- cls : InputType [T ],
742- default : Default ,
743- * ,
744- threadsafe : bool | None = ...,
745- ) -> Invertible [T | Default ]: ...
746-
747- @overload
748- def get_lazy_instance [T ](
749- self ,
750- cls : InputType [T ],
751- default : T = ...,
752- * ,
753- threadsafe : bool | None = ...,
754- ) -> Invertible [T ]: ...
747+ if TYPE_CHECKING : # pragma: no cover
748+
749+ @overload
750+ def get_lazy_instance [T , Default ](
751+ self ,
752+ cls : InputType [T ],
753+ default : Default ,
754+ * ,
755+ threadsafe : bool | None = ...,
756+ ) -> Invertible [T | Default ]: ...
757+
758+ @overload
759+ def get_lazy_instance [T ](
760+ self ,
761+ cls : InputType [T ],
762+ default : T = ...,
763+ * ,
764+ threadsafe : bool | None = ...,
765+ ) -> Invertible [T ]: ...
755766
756767 def get_lazy_instance [T , Default ](
757768 self ,
0 commit comments