typing_extensions icon indicating copy to clipboard operation
typing_extensions copied to clipboard

Copy the coroutine status in deprecated

Open srittau opened this issue 1 year ago • 3 comments

srittau avatar Jul 23 '24 10:07 srittau

On earlier versions of Python, there were two different functions, inspect.iscoroutinefunction and asyncio.coroutines.iscoroutinefunction. This was confusing, because they did two different things: inspect.iscoroutinefunction was strict about only returning True for functions that actually had the CO_COROUTINE code-flag set, whereas asyncio.coroutines.iscoroutinefunction also considered functions decorated with @types.coroutine to be coroutines, even though these functions did not have that code-flag set.

There's not much we can do for inspect.iscoroutinefunction on the earlier versions of Python (because, before the two iscoroutinefunction functions were merged, it was stricter than it is now), but we can hack asyncio.coroutines.iscoroutinefunction by doing decorated_function._is_coroutine = asyncio.coroutines._is_coroutine: https://github.com/python/cpython/blob/d542a9be51776e8d589363ee15164dec8dbd3a76/Lib/asyncio/coroutines.py#L17-L24

AlexWaygood avatar Jul 23 '24 10:07 AlexWaygood

The 3.13 test fails, because this hasn't been implemented in 3.13 yet. It should be fixed with 3.13.rc1. What's the best course of action?

srittau avatar Jul 23 '24 10:07 srittau

The 3.13 test fails, because this hasn't been implemented in 3.13 yet. It should be fixed with 3.13.rc1. What's the best course of action?

I'd add a decorator like the one we already have here (which we can probably delete at this point):

https://github.com/python/typing_extensions/blob/70cec91bec65155dc339d631ede2a933582558df/src/test_typing_extensions.py#L125-L128

Something like this:

 skip_if_py313_beta = skipIf( 
     sys.version_info[:4] == (3, 13, 0, 'beta'), 
     "Bugfixes will be released in 3.13.0rc1"
 )

AlexWaygood avatar Jul 23 '24 10:07 AlexWaygood

CI is passing now.

srittau avatar Aug 29 '24 15:08 srittau