11from __future__ import annotations
22
33import inspect
4- from collections .abc import Awaitable , Callable , Coroutine
5- from types import CoroutineType
4+ from collections .abc import AsyncGenerator , Awaitable , Callable , Coroutine , Generator
65from typing import Any
76from typing_extensions import assert_type
87
@@ -17,10 +16,24 @@ def test_iscoroutinefunction_inspect(
1716 assert_type (x , Callable [[str , int ], Coroutine [str , int , bytes ]])
1817
1918 if inspect .iscoroutinefunction (y ):
20- assert_type (y , Callable [[str , int ], CoroutineType [Any , Any , bytes ]])
19+ assert_type (y , Callable [[str , int ], Coroutine [Any , Any , bytes ]])
2120
2221 if inspect .iscoroutinefunction (z ):
23- assert_type (z , Callable [[str , int ], CoroutineType [Any , Any , Any ]])
22+ assert_type (z , Callable [[str , int ], Coroutine [Any , Any , Any ]])
2423
2524 if inspect .iscoroutinefunction (xx ):
26- assert_type (xx , Callable [..., CoroutineType [Any , Any , Any ]])
25+ assert_type (xx , Callable [..., Coroutine [Any , Any , Any ]])
26+
27+
28+ def test_isgeneratorfunction_inspect (x : Callable [[str ], object ], y : object ) -> None :
29+ if inspect .isgeneratorfunction (x ):
30+ assert_type (x , Callable [[str ], Generator [Any , Any , Any ]])
31+ if inspect .isgeneratorfunction (y ):
32+ assert_type (y , Callable [..., Generator [Any , Any , Any ]])
33+
34+
35+ def test_isasyncgenfunction_inspect (x : Callable [[str ], object ], y : object ) -> None :
36+ if inspect .isasyncgenfunction (x ):
37+ assert_type (x , Callable [[str ], AsyncGenerator [Any , Any ]])
38+ if inspect .isasyncgenfunction (y ):
39+ assert_type (y , Callable [..., AsyncGenerator [Any , Any ]])
0 commit comments