python-dependency-injector/tests/typing/coroutine.py
Leonardus Chen 13847c0ce6
Retrofit assert type for some type-stub checks (#943)
Retrofit assert type for:

- configuration.py
- container.py
- declarative_container.py
- delegate.py
- dependencies_container.py
- dependency.py
- dict.py
- dynamic_container.py
2026-01-31 15:34:10 +02:00

19 lines
494 B
Python

from typing import Awaitable, Coroutine, Any
from typing_extensions import assert_type
from dependency_injector import providers
async def _coro() -> None: ...
# Test 1: to check the return type
provider1 = providers.Coroutine(_coro)
var1 = provider1()
assert_type(var1, Coroutine[Any, Any, None]) # type: ignore[unused-coroutine]
# Test 2: to check string imports
provider2 = providers.Coroutine("_coro")
provider2.set_provides("_coro")
assert_type(provider2, providers.Coroutine[Any])