Skip to content

Python: Replace deprecated asyncio.iscoroutinefunction with inspect.iscoroutinefunction#4552

Open
ogkranthi wants to merge 2 commits intomicrosoft:mainfrom
ogkranthi:fix/replace-deprecated-asyncio-iscoroutinefunction
Open

Python: Replace deprecated asyncio.iscoroutinefunction with inspect.iscoroutinefunction#4552
ogkranthi wants to merge 2 commits intomicrosoft:mainfrom
ogkranthi:fix/replace-deprecated-asyncio-iscoroutinefunction

Conversation

@ogkranthi
Copy link

Summary

  • Replaces all remaining asyncio.iscoroutinefunction() calls with inspect.iscoroutinefunction() in test files
  • asyncio.iscoroutinefunction() is deprecated since Python 3.14
  • Production code already uses inspect.iscoroutinefunction() — only test files had the deprecated usage

Fixes #4522

Changes

  • python/packages/core/tests/workflow/test_function_executor.py — replaced 3 usages, added import inspect
  • python/packages/devui/tests/devui/test_cleanup_hooks.py — replaced 1 usage, added import inspect

Test plan

  • Verify tests pass on Python 3.14 without deprecation warnings
  • Confirm no other asyncio.iscoroutinefunction usages remain in codebase

…scoroutinefunction

Fixes microsoft#4522. asyncio.iscoroutinefunction() is deprecated since Python 3.14.
Replaced all remaining usages in test files with inspect.iscoroutinefunction().
Copilot AI review requested due to automatic review settings March 9, 2026 04:06
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates Python test suites to avoid the deprecated asyncio.iscoroutinefunction() (deprecated in Python 3.14) by switching to inspect.iscoroutinefunction(), aligning tests with existing production-code behavior.

Changes:

  • Replaced asyncio.iscoroutinefunction() with inspect.iscoroutinefunction() in core workflow tests.
  • Replaced asyncio.iscoroutinefunction() with inspect.iscoroutinefunction() in DevUI cleanup hook tests.
  • Updated imports and one test docstring to reflect inspect usage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
python/packages/core/tests/workflow/test_function_executor.py Switches coroutine-function detection in a staticmethod-descriptor behavior test to use inspect.iscoroutinefunction().
python/packages/devui/tests/devui/test_cleanup_hooks.py Switches coroutine-function detection when executing cleanup hooks to use inspect.iscoroutinefunction() and adds the corresponding import.

You can also share your feedback on Copilot code review. Take the survey.

"""Tests for cleanup hook registration and execution."""

import asyncio
import inspect
Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

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

inspect is now imported at module scope; the additional import inspect statements inside individual tests are redundant. Consider removing the inner imports to keep imports consistent and avoid duplication.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

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

@copilot open a new pull request to apply changes based on this feedback

@markwallace-microsoft
Copy link
Member

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
TOTAL22676257588% 
report-only-changed-files is enabled. No files were changed during this commit :)

Python Unit Test Overview

Tests Skipped Failures Errors Time
4930 20 💤 0 ❌ 0 🔥 1m 19s ⏱️

@ogkranthi
Copy link
Author

@copilot open a new pull request to apply changes based on the comments in this thread

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: asyncio.iscoroutinefunction is deprecated

3 participants