Skip to content

Commit 10552f9

Browse files
committed
Use TypeVar with default Any for Selector
1 parent 059f78b commit 10552f9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/dependency_injector/providers.pyi

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ from contextlib import AbstractContextManager, AbstractAsyncContextManager
44
from pathlib import Path
55
from typing import (
66
Awaitable,
7-
TypeVar,
87
Generic,
98
Type,
109
Callable as _Callable,
@@ -22,6 +21,8 @@ from typing import (
2221
overload,
2322
)
2423

24+
from typing_extensions import TypeVar
25+
2526
try:
2627
import yaml
2728
except ImportError:
@@ -38,6 +39,7 @@ Injection = Any
3839
ProviderParent = Union["Provider", Any]
3940
T = TypeVar("T")
4041
TT = TypeVar("TT")
42+
T_Any = TypeVar("T_Any", default=Any)
4143
P = TypeVar("P", bound="Provider")
4244
BS = TypeVar("BS", bound="BaseSingleton")
4345

@@ -542,17 +544,17 @@ class Container(Provider[T]):
542544
def parent_name(self) -> Optional[str]: ...
543545
def assign_parent(self, parent: ProviderParent) -> None: ...
544546

545-
class Selector(Provider[Any]):
547+
class Selector(Provider[T_Any]):
546548
def __init__(
547549
self, selector: Optional[_Callable[..., Any]] = None, **providers: Provider
548550
): ...
549551
def __getattr__(self, name: str) -> Provider: ...
550552
@property
551553
def selector(self) -> Optional[_Callable[..., Any]]: ...
552-
def set_selector(self, selector: Optional[_Callable[..., Any]]) -> Selector: ...
554+
def set_selector(self, selector: Optional[_Callable[..., Any]]) -> Selector[T_Any]: ...
553555
@property
554556
def providers(self) -> _Dict[str, Provider]: ...
555-
def set_providers(self, **providers: Provider) -> Selector: ...
557+
def set_providers(self, **providers: Provider) -> Selector[TT]: ...
556558

557559
class ProvidedInstanceFluentInterface:
558560
def __getattr__(self, item: Any) -> AttributeGetter: ...

0 commit comments

Comments
 (0)