mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-11-24 11:55:47 +03:00
Use TypeVar with default Any for Selector
This commit is contained in:
parent
059f78b27c
commit
10552f9284
|
|
@ -4,7 +4,6 @@ from contextlib import AbstractContextManager, AbstractAsyncContextManager
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import (
|
from typing import (
|
||||||
Awaitable,
|
Awaitable,
|
||||||
TypeVar,
|
|
||||||
Generic,
|
Generic,
|
||||||
Type,
|
Type,
|
||||||
Callable as _Callable,
|
Callable as _Callable,
|
||||||
|
|
@ -22,6 +21,8 @@ from typing import (
|
||||||
overload,
|
overload,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from typing_extensions import TypeVar
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import yaml
|
import yaml
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
@ -38,6 +39,7 @@ Injection = Any
|
||||||
ProviderParent = Union["Provider", Any]
|
ProviderParent = Union["Provider", Any]
|
||||||
T = TypeVar("T")
|
T = TypeVar("T")
|
||||||
TT = TypeVar("TT")
|
TT = TypeVar("TT")
|
||||||
|
T_Any = TypeVar("T_Any", default=Any)
|
||||||
P = TypeVar("P", bound="Provider")
|
P = TypeVar("P", bound="Provider")
|
||||||
BS = TypeVar("BS", bound="BaseSingleton")
|
BS = TypeVar("BS", bound="BaseSingleton")
|
||||||
|
|
||||||
|
|
@ -542,17 +544,17 @@ class Container(Provider[T]):
|
||||||
def parent_name(self) -> Optional[str]: ...
|
def parent_name(self) -> Optional[str]: ...
|
||||||
def assign_parent(self, parent: ProviderParent) -> None: ...
|
def assign_parent(self, parent: ProviderParent) -> None: ...
|
||||||
|
|
||||||
class Selector(Provider[Any]):
|
class Selector(Provider[T_Any]):
|
||||||
def __init__(
|
def __init__(
|
||||||
self, selector: Optional[_Callable[..., Any]] = None, **providers: Provider
|
self, selector: Optional[_Callable[..., Any]] = None, **providers: Provider
|
||||||
): ...
|
): ...
|
||||||
def __getattr__(self, name: str) -> Provider: ...
|
def __getattr__(self, name: str) -> Provider: ...
|
||||||
@property
|
@property
|
||||||
def selector(self) -> Optional[_Callable[..., Any]]: ...
|
def selector(self) -> Optional[_Callable[..., Any]]: ...
|
||||||
def set_selector(self, selector: Optional[_Callable[..., Any]]) -> Selector: ...
|
def set_selector(self, selector: Optional[_Callable[..., Any]]) -> Selector[T_Any]: ...
|
||||||
@property
|
@property
|
||||||
def providers(self) -> _Dict[str, Provider]: ...
|
def providers(self) -> _Dict[str, Provider]: ...
|
||||||
def set_providers(self, **providers: Provider) -> Selector: ...
|
def set_providers(self, **providers: Provider) -> Selector[TT]: ...
|
||||||
|
|
||||||
class ProvidedInstanceFluentInterface:
|
class ProvidedInstanceFluentInterface:
|
||||||
def __getattr__(self, item: Any) -> AttributeGetter: ...
|
def __getattr__(self, item: Any) -> AttributeGetter: ...
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user