mirror of
https://github.com/ets-labs/python-dependency-injector.git
synced 2025-12-28 12:32:59 +03:00
Replace Coroutine typevar T with T_Any and retrofit assert_type on coroutine
This commit is contained in:
parent
635c755d74
commit
b95e22ecb3
|
|
@ -197,7 +197,7 @@ class AbstractCallable(Callable[T]):
|
|||
class CallableDelegate(Delegate):
|
||||
def __init__(self, callable: Callable) -> None: ...
|
||||
|
||||
class Coroutine(Callable[T]): ...
|
||||
class Coroutine(Callable[T_Any]): ...
|
||||
class DelegatedCoroutine(Coroutine[T]): ...
|
||||
|
||||
class AbstractCoroutine(Coroutine[T]):
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
from typing import Awaitable, Coroutine
|
||||
from typing import Awaitable, Coroutine, Any
|
||||
from typing_extensions import assert_type
|
||||
|
||||
from dependency_injector import providers
|
||||
|
||||
|
|
@ -8,8 +9,10 @@ async def _coro() -> None: ...
|
|||
|
||||
# Test 1: to check the return type
|
||||
provider1 = providers.Coroutine(_coro)
|
||||
var1: Awaitable[None] = provider1()
|
||||
var1 = provider1()
|
||||
assert_type(var1, Coroutine[Any, Any, None]) # type: ignore[unused-coroutine]
|
||||
|
||||
# Test 2: to check string imports
|
||||
provider2: providers.Coroutine[None] = providers.Coroutine("_coro")
|
||||
provider2 = providers.Coroutine("_coro")
|
||||
provider2.set_provides("_coro")
|
||||
assert_type(provider2, providers.Coroutine[Any])
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user