mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-10-11 14:26:37 +03:00
Add stubs for Coroutine providers
This commit is contained in:
parent
027a72d3b1
commit
294eec1f27
|
@ -1,6 +1,17 @@
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
from typing import TypeVar, Generic, Type, Callable as _Callable, Any, Tuple, Optional, Dict, Union
|
from typing import (
|
||||||
|
TypeVar,
|
||||||
|
Generic,
|
||||||
|
Type,
|
||||||
|
Callable as _Callable,
|
||||||
|
Any,
|
||||||
|
Tuple,
|
||||||
|
Optional,
|
||||||
|
Dict,
|
||||||
|
Union,
|
||||||
|
Coroutine as _Coroutine,
|
||||||
|
)
|
||||||
|
|
||||||
Injection = Any
|
Injection = Any
|
||||||
T = TypeVar('T')
|
T = TypeVar('T')
|
||||||
|
@ -92,6 +103,20 @@ class CallableDelegate(Delegate):
|
||||||
def __init__(self, callable: Callable) -> None: ...
|
def __init__(self, callable: Callable) -> None: ...
|
||||||
|
|
||||||
|
|
||||||
|
class Coroutine(Callable): ...
|
||||||
|
|
||||||
|
|
||||||
|
class DelegatedCoroutine(Coroutine): ...
|
||||||
|
|
||||||
|
|
||||||
|
class AbstractCoroutine(Coroutine):
|
||||||
|
def override(self, provider: Coroutine) -> OverridingContext: ...
|
||||||
|
|
||||||
|
|
||||||
|
class CoroutineDelegate(Delegate):
|
||||||
|
def __init__(self, coroutine: Coroutine) -> None: ...
|
||||||
|
|
||||||
|
|
||||||
class Factory(Provider, Generic[T]):
|
class Factory(Provider, Generic[T]):
|
||||||
provided_type: Optional[Type]
|
provided_type: Optional[Type]
|
||||||
def __init__(self, provides: _Callable[..., T], *args: Injection, **kwargs: Injection) -> None: ...
|
def __init__(self, provides: _Callable[..., T], *args: Injection, **kwargs: Injection) -> None: ...
|
||||||
|
|
11
tests/typing/coroutine.py
Normal file
11
tests/typing/coroutine.py
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
from typing import Coroutine
|
||||||
|
|
||||||
|
from dependency_injector import providers
|
||||||
|
|
||||||
|
|
||||||
|
async def _coro() -> None:
|
||||||
|
...
|
||||||
|
|
||||||
|
# Test 1: to check the return type
|
||||||
|
provider1 = providers.Coroutine(_coro)
|
||||||
|
var1: Coroutine = provider1()
|
Loading…
Reference in New Issue
Block a user