mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-28 22:56:55 +08:00
inspect, asyncio: Use more TypeGuards (#8057)
This commit is contained in:
24
test_cases/stdlib/asyncio/test_coroutines.py
Normal file
24
test_cases/stdlib/asyncio/test_coroutines.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from asyncio import iscoroutinefunction
|
||||
from collections.abc import Awaitable, Callable, Coroutine
|
||||
from typing import Any, Union
|
||||
from typing_extensions import assert_type
|
||||
|
||||
|
||||
def test_iscoroutinefunction(
|
||||
x: Callable[[str, int], Coroutine[str, int, bytes]],
|
||||
y: Callable[[str, int], Awaitable[bytes]],
|
||||
z: Callable[[str, int], Union[str, Awaitable[bytes]]],
|
||||
xx: object,
|
||||
) -> None:
|
||||
|
||||
if iscoroutinefunction(x):
|
||||
assert_type(x, Callable[[str, int], Coroutine[str, int, bytes]])
|
||||
|
||||
if iscoroutinefunction(y):
|
||||
assert_type(y, Callable[[str, int], Coroutine[Any, Any, bytes]])
|
||||
|
||||
if iscoroutinefunction(z):
|
||||
assert_type(z, Callable[[str, int], Coroutine[Any, Any, Any]])
|
||||
|
||||
if iscoroutinefunction(xx):
|
||||
assert_type(xx, Callable[..., Coroutine[Any, Any, Any]])
|
||||
Reference in New Issue
Block a user