Skip to content

Conversation

@hyongtao-code
Copy link
Contributor

@hyongtao-code hyongtao-code commented Jan 21, 2026

Fix a documentation typo: isasyncgenfunction() applies to asynchronous generator functions, not coroutine functions.

Test python script

import functools
import inspect

async def agen():
    yield 1
    yield 2

print(inspect.isasyncgenfunction(agen))     # output: True
print(inspect.iscoroutinefunction(agen))    # output: Fasle
print(inspect.isgeneratorfunction(agen))    # output: Fasle

class C:
    async def agen2(self):
        yield 1
    
    agen2_pm = functools.partialmethod(agen2)

print(inspect.isasyncgenfunction(C.agen2))  # output: True
print(inspect.iscoroutinefunction(C.agen2)) # output: Fasle
print(inspect.isgeneratorfunction(C.agen2)) # output: Fasle

print(inspect.isasyncgenfunction(C.agen2_pm))  # output: True  <------------------- !!!
print(inspect.iscoroutinefunction(C.agen2_pm)) # output: Fasle
print(inspect.isgeneratorfunction(C.agen2_pm)) # output: Fasle

📚 Documentation preview 📚: https://cpython-previews--144099.org.readthedocs.build/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

2 participants