Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced asyncio.coroutines.iscoroutinefunction with inspect.iscoroutinefunction #1267

Conversation

davorrunje
Copy link
Collaborator

@davorrunje davorrunje commented Jan 15, 2024

Why are these changes needed?

In several places asyncio.coroutines.iscoroutinefunction was used instead of inspect.iscoroutinefunction.

Both asyncio.coroutines.iscoroutinefunction and inspect.iscoroutinefunction are used to check if a function is a coroutine function. However, they differ in the types of functions they consider to be coroutine functions.

  • inspect.iscoroutinefunction considers a function to be a coroutine function if it is either:

    • A function decorated with async def
    • A function decorated with @asyncio.coroutine
  • asyncio.coroutines.iscoroutinefunction only considers a function to be a coroutine function if it is decorated with @asyncio.coroutine. It does not consider functions decorated with async def to be coroutine functions.

See e.g. https://stackoverflow.com/questions/59343239/asyncio-iscoroutinefunction-returns-false-for-asynchronous-generator

Related issue number

Closes #1260

Checks

@codecov-commenter
Copy link

codecov-commenter commented Jan 15, 2024

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (135bca4) 32.11% compared to head (4c0953b) 51.09%.

Files Patch % Lines
autogen/agentchat/conversable_agent.py 62.50% 1 Missing and 2 partials ⚠️
autogen/agentchat/contrib/compressible_agent.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1267       +/-   ##
===========================================
+ Coverage   32.11%   51.09%   +18.98%     
===========================================
  Files          32       32               
  Lines        4391     4392        +1     
  Branches     1024     1079       +55     
===========================================
+ Hits         1410     2244      +834     
+ Misses       2865     1944      -921     
- Partials      116      204       +88     
Flag Coverage Δ
unittests 51.02% <60.00%> (+18.95%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ekzhu ekzhu requested a review from qingyun-wu January 15, 2024 21:05
@ekzhu
Copy link
Collaborator

ekzhu commented Jan 15, 2024

@qingyun-wu

Copy link
Contributor

@qingyun-wu qingyun-wu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks!

@qingyun-wu qingyun-wu added this pull request to the merge queue Jan 16, 2024
Merged via the queue into main with commit bde2fc9 Jan 16, 2024
87 checks passed
whiskyboy pushed a commit to whiskyboy/autogen that referenced this pull request Apr 17, 2024
@jackgerrits jackgerrits deleted the 1260-bug-use-of-asynciocoroutinesiscoroutinefunction-instead-of-inspectiscoroutinefunction branch September 25, 2024 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: use of asyncio.coroutines.iscoroutinefunction instead of inspect.iscoroutinefunction
4 participants