@@ -73,6 +73,8 @@ def my_config(binder):
7373 inject.configure(my_config)
7474
7575"""
76+ from __future__ import annotations
77+
7678import contextlib
7779
7880from inject ._version import __version__
@@ -84,7 +86,7 @@ def my_config(binder):
8486from functools import wraps
8587from typing import (Any , Awaitable , Callable , Dict , Generic , Hashable ,
8688 Optional , Set , Type , TypeVar , Union , cast , get_type_hints ,
87- overload , no_type_check , Self )
89+ overload , no_type_check )
8890
8991_HAS_PEP604_SUPPORT = sys .version_info [:3 ] >= (3 , 10 , 0 ) # PEP 604
9092if _HAS_PEP604_SUPPORT :
@@ -214,8 +216,12 @@ def __init__(
214216 else :
215217 self ._bindings = {}
216218
219+ # NOTE(pyctrl): only since 3.12
220+ # @overload
221+ # def get_instance(self, cls: Type[T]) -> T: ...
222+
217223 @overload
218- def get_instance (self , cls : Type [ T ] ) -> T : ...
224+ def get_instance (self , cls : Binding ) -> T : ...
219225
220226 @overload
221227 def get_instance (self , cls : Hashable ) -> Injectable : ...
@@ -521,11 +527,19 @@ def sign_up(name, email, cache, db):
521527 return _ParametersInjection (** args_to_classes )
522528
523529
530+ # NOTE(pyctrl): only since 3.12
531+ # @overload
532+ # def autoparams[T](fn: Callable[..., T]) -> Callable[..., T]: ...
533+
524534@overload
525- def autoparams [T ](fn : Callable [..., T ]) -> Callable [..., T ]: ...
535+ def autoparams (fn : Callable ) -> Callable : ...
536+
537+ # NOTE(pyctrl): only since 3.12
538+ # @overload
539+ # def autoparams[C: Callable](*selected: str) -> Callable[[C], C]: ...
526540
527541@overload
528- def autoparams [ C : Callable ] (* selected : str ) -> Callable [[ C ], C ] : ...
542+ def autoparams (* selected : str ) -> Callable : ...
529543
530544@no_type_check
531545def autoparams (* selected : str ):
0 commit comments