Skip to content

typing_extensions.deprecated and warnings.deprecated remove coroutine property; How to deprecate async functions? #122088

Closed
@Kakadus

Description

@Kakadus

When I annotate an async function with @deprecated(...), inspect.iscoroutinefunction no longer returns True. This is not what I expect to happen, as with partial from functools this does not happen.

Consider the following code:

import inspect

from functools import partial
from typing_extensions import deprecated


async def coroutinefunction_a():
    pass


@deprecated("deprecated coroutine")
async def coroutinefunction_b():
    pass


assert inspect.iscoroutinefunction(coroutinefunction_a) is True  # correct
assert inspect.iscoroutinefunction(partial(coroutinefunction_a)) is True  # correct
assert inspect.iscoroutinefunction(coroutinefunction_b) is True  # fail

With typing_extensions and python3.13, the last assertion fails.

This is especially annoying since e.g. libraries use inspect.iscoroutinefunction to detect the type of function.

I am not sure this is the correct place for this bug report, as this both happens with python 3.13 and typing_extensions on older python versions.

Linked PRs

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions