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

Switch from asyncio.iscoroutinefunction to inspect. #637

Merged

Conversation

frenzymadness
Copy link
Contributor

The former causes: DeprecationWarning:
'asyncio.iscoroutinefunction' is deprecated and slated for removal in Python 3.16; use inspect.iscoroutinefunction() instead.

Fixes: #635

What do these changes do?

See the description in the commit message.

Are there changes in behavior for the user?

No

Related issue number

#635

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes

@Dreamsorcerer
Copy link
Member

3.14 is still failing due to the same function call happening in pytest-asyncio.
Older versions are failing because the inspect function doesn't seem to behave the same (hopefully only on older releases...).

@frenzymadness frenzymadness force-pushed the fix_pendingdeprecationwarning branch from 2a84d89 to ec1c2b9 Compare January 21, 2025 11:48
The former causes: DeprecationWarning:
'asyncio.iscoroutinefunction' is deprecated and slated for removal
in Python 3.16; use inspect.iscoroutinefunction() instead.

Fixes: aio-libs#635
@frenzymadness frenzymadness force-pushed the fix_pendingdeprecationwarning branch from ec1c2b9 to c2a83bb Compare January 21, 2025 11:51
@frenzymadness
Copy link
Contributor Author

I've implemented it in a way that older Pythons use the old way. pytest-asyncio is already fixed in the latest version: pytest-dev/pytest-asyncio@d043698 but I'm afraid it will cause the same issue for older Python as we saw here. Let's see what the tests tell us.

Copy link

codecov bot commented Jan 21, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.00%. Comparing base (f60bf71) to head (44b0934).
Report is 101 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #637      +/-   ##
==========================================
+ Coverage   96.88%   97.00%   +0.11%     
==========================================
  Files          12       12              
  Lines         770      800      +30     
  Branches       91       41      -50     
==========================================
+ Hits          746      776      +30     
  Misses         22       22              
  Partials        2        2              
Flag Coverage Δ
unit 95.62% <60.00%> (-1.13%) ⬇️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Dreamsorcerer
Copy link
Member

Ah, Dependabot got stuck from 3.8 still being in the tests. Let me clear the Dependabot PRs quickly, which will get us an updated pytest-asyncio.

@Dreamsorcerer
Copy link
Member

Looks like pytest-asyncio still needs some updates. Now it's DeprecationWarning: 'asyncio.get_event_loop_policy' is deprecated and slated for removal in Python 3.16.

@frenzymadness
Copy link
Contributor Author

Reported: pytest-dev/pytest-asyncio#1049

@Dreamsorcerer
Copy link
Member

Doesn't look like it'll be fixed for a while, so we should probably ignore the warning in pytest-asyncio.
Should be able to add an ignore rule to the config, similar to https://github.com/aio-libs/aiohttp/blob/b1fd3463f1d47919235f86d01e4cda3822450868/setup.cfg#L158

@Dreamsorcerer
Copy link
Member

That's pytest-asyncio ignored, but still get 4 failures as it seems that the inspect function is still not equivalent of the asyncio one...

@Dreamsorcerer
Copy link
Member

That's actually one more failure than we saw on older releases, suggesting the inspect function is actually less compatible in 3.14 than previous releases.

@Dreamsorcerer Dreamsorcerer merged commit 4df3785 into aio-libs:master Mar 30, 2025
25 checks passed
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.

DeprecationWarning: asyncio.iscoroutinefunction
2 participants