Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[3.11] gh-84753: Make inspect.iscoroutinefunction() work with AsyncMock (GH-94050)#94460

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ambv merged 1 commit intopython:3.11frommiss-islington:backport-4261b6b-3.11
Jun 30, 2022

Conversation

@miss-islington
Copy link
Contributor

@miss-islingtonmiss-islington commentedJun 30, 2022
edited by bedevere-bot
Loading

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 inasyncio.iscoroutinefunction.

Co-authored-by: Łukasz Langalukasz@langa.pl
(cherry picked from commit4261b6b)

Co-authored-by: Mehdi ABAAKOUKsileht@sileht.net

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 oneperformed in `asyncio.iscoroutinefunction`.Co-authored-by: Łukasz Langa <lukasz@langa.pl>(cherry picked from commit4261b6b)Co-authored-by: Mehdi ABAAKOUK <sileht@sileht.net>
@miss-islington
Copy link
ContributorAuthor

Status check is done, and it's a success ✅ .

@miss-islington
Copy link
ContributorAuthor

Status check is done, and it's a success ✅ .

@ambvambv merged commit9ebec7d intopython:3.11Jun 30, 2022
@miss-islingtonmiss-islington deleted the backport-4261b6b-3.11 branchJune 30, 2022 18:05
@graingert
Copy link
Contributor

Isn't 3.11 and 3.10 in feature freeze? Cc@pablogsal

@pablogsal
Copy link
Member

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 identifyingAsyncMock as not a coroutine. If we were raising or doing something different then that would have been an incompatible change or a new feature, but the current behaviour is wrong.

Maybe I am missing something, thought.

@graingert
Copy link
Contributor

I read this as a feature change to allow duck typed Function-like objects to pass iscoroutinefunction/isgeneratorfunction/isasyncgeneratorfunction

@pablogsal
Copy link
Member

pablogsal commentedJul 3, 2022
edited
Loading

All the descriptions of the issue and the tests are aboutAsyncMock and the way the original issue is written and the code is as if the current behaviour is a bug. Are you concerns around that this affects more than justAsyncMock?

@pablogsal
Copy link
Member

@ambv Thoughts?

@graingert
Copy link
Contributor

graingert commentedJul 3, 2022
edited
Loading

Are you concerns around that this affects more than just AsyncMock?

Yeah this affects both more than AsyncMock and more than iscoroutinefunction

@graingert
Copy link
Contributor

Also the notes in the PR reflect the old approach and not the approach used in the code:

The fix introduces special-casing of AsyncMock in
inspect.iscoroutinefunction equivalent to the one
performed in asyncio.iscoroutinefunction.

@pablogsal
Copy link
Member

Hummm,@ambv I think this should then not have been backported. We should revert both backports

@cjw296
Copy link
Contributor

I dunno, this feels like a bug that is being fixed.
@graingert - what situations are you concerned about where thiswouldn't be a bug fix?

@ambv
Copy link
Contributor

ambv commentedJul 4, 2022

I agree with@cjw296 that this is a bug fix. Instead of hard-codingAsyncMock as a type ininspect, we use a more generic version, which catches AsyncMock fine. The duck type needs to be very thorough to pass the test. This method was introduced for Cython functions.

I agree that the description of the PR could better indicate what the change is vs what problem it fixes.

@pablogsal
Copy link
Member

we use a more generic version, which catches AsyncMock fine. The duck type needs to be very thorough to pass the test. This method was introduced for Cython functions.

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.

@pablogsal
Copy link
Member

I agree that the description of the PR could better indicate what the change is vs what problem it fixes.

At the very least, lest improve the NEWS entry, please.

cjw296 reacted with thumbs up emoji

@cjw296
Copy link
Contributor

Well, but wouldn't this affect other code that currently is behaving in a (arguably incorrect) given way?

If it's behaving in an incorrect way before this fix, isn't that just another indication this is a bugfix?

ambv reacted with thumbs up emoji

@pablogsal
Copy link
Member

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.

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

Reviewers

@cjw296cjw296Awaiting requested review from cjw296cjw296 is a code owner

@1st11st1Awaiting requested review from 1st11st1 is a code owner

@asvetlovasvetlovAwaiting requested review from asvetlovasvetlov is a code owner

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

7 participants

@miss-islington@graingert@pablogsal@cjw296@ambv@bedevere-bot@sileht

[8]ページ先頭

©2009-2025 Movatter.jp