-
-
Notifications
You must be signed in to change notification settings - Fork 31.5k
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
[3.11] gh-84753: Make inspect.iscoroutinefunction() work with AsyncMock (GH-94050) #94460
Conversation
pythonGH-94050) The inspect version was not working with unittest.mock.AsyncMock. The fix introduces special-casing of AsyncMock in `inspect.iscoroutinefunction` equivalent to the one performed in `asyncio.iscoroutinefunction`. Co-authored-by: Łukasz Langa <lukasz@langa.pl> (cherry picked from commit 4261b6b) Co-authored-by: Mehdi ABAAKOUK <sileht@sileht.net>
Status check is done, and it's a success ✅ . |
Status check is done, and it's a success ✅ . |
Isn't 3.11 and 3.10 in feature freeze? Cc @pablogsal |
This is a bugfix, isn't it? The bug being they is was incorrectly identifying Maybe I am missing something, thought. |
I read this as a feature change to allow duck typed Function-like objects to pass iscoroutinefunction/isgeneratorfunction/isasyncgeneratorfunction |
All the descriptions of the issue and the tests are about |
@ambv Thoughts? |
Yeah this affects both more than AsyncMock and more than iscoroutinefunction |
Also the notes in the PR reflect the old approach and not the approach used in the code:
|
Hummm, @ambv I think this should then not have been backported. We should revert both backports |
I dunno, this feels like a bug that is being fixed. |
I agree with @cjw296 that this is a bug fix. Instead of hard-coding I agree that the description of the PR could better indicate what the change is vs what problem it fixes. |
Well, but wouldn't this affect other code that currently is behaving in a (arguably incorrect) given way? Technically that prevents the backport unless all possible affected code is surely doing it wrong. |
At the very least, lest improve the NEWS entry, please. |
If it's behaving in an incorrect way before this fix, isn't that just another indication this is a bugfix? |
Yes, as long as every affected case is behaving incorrectly. |
The inspect version was not working with unittest.mock.AsyncMock.
The fix introduces special-casing of AsyncMock in
inspect.iscoroutinefunction
equivalent to the oneperformed in
asyncio.iscoroutinefunction
.Co-authored-by: Łukasz Langa lukasz@langa.pl
(cherry picked from commit 4261b6b)
Co-authored-by: Mehdi ABAAKOUK sileht@sileht.net