Skip to content

Commit b95e22e

Browse files
committed
Replace Coroutine typevar T with T_Any and retrofit assert_type on coroutine
1 parent 635c755 commit b95e22e

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

src/dependency_injector/providers.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class AbstractCallable(Callable[T]):
197197
class CallableDelegate(Delegate):
198198
def __init__(self, callable: Callable) -> None: ...
199199

200-
class Coroutine(Callable[T]): ...
200+
class Coroutine(Callable[T_Any]): ...
201201
class DelegatedCoroutine(Coroutine[T]): ...
202202

203203
class AbstractCoroutine(Coroutine[T]):

tests/typing/coroutine.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from typing import Awaitable, Coroutine
1+
from typing import Awaitable, Coroutine, Any
2+
from typing_extensions import assert_type
23

34
from dependency_injector import providers
45

@@ -8,8 +9,10 @@ async def _coro() -> None: ...
89

910
# Test 1: to check the return type
1011
provider1 = providers.Coroutine(_coro)
11-
var1: Awaitable[None] = provider1()
12+
var1 = provider1()
13+
assert_type(var1, Coroutine[Any, Any, None]) # type: ignore[unused-coroutine]
1214

1315
# Test 2: to check string imports
14-
provider2: providers.Coroutine[None] = providers.Coroutine("_coro")
16+
provider2 = providers.Coroutine("_coro")
1517
provider2.set_provides("_coro")
18+
assert_type(provider2, providers.Coroutine[Any])

0 commit comments

Comments
 (0)