From 6f62845573ada98313bf46fde3d24bc546be2d6a Mon Sep 17 00:00:00 2001 From: Kranthi Kumar Manchikanti Date: Mon, 9 Mar 2026 00:03:10 -0400 Subject: [PATCH 1/2] Python: Replace deprecated asyncio.iscoroutinefunction with inspect.iscoroutinefunction Fixes #4522. asyncio.iscoroutinefunction() is deprecated since Python 3.14. Replaced all remaining usages in test files with inspect.iscoroutinefunction(). --- .../core/tests/workflow/test_function_executor.py | 9 +++++---- python/packages/devui/tests/devui/test_cleanup_hooks.py | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/python/packages/core/tests/workflow/test_function_executor.py b/python/packages/core/tests/workflow/test_function_executor.py index 8bb3f94d29..a7803a735e 100644 --- a/python/packages/core/tests/workflow/test_function_executor.py +++ b/python/packages/core/tests/workflow/test_function_executor.py @@ -529,11 +529,12 @@ async def bad_handler(cls, data: str) -> str: assert "@handler on instance methods" in str(exc_info.value) async def test_async_staticmethod_detection_behavior(self): - """Document the behavior of asyncio.iscoroutinefunction with staticmethod descriptors. + """Document the behavior of inspect.iscoroutinefunction with staticmethod descriptors. This test explains why the unwrapping is necessary when decorators are stacked. """ import asyncio + import inspect # When @staticmethod is applied, it creates a descriptor async def my_async_func(): @@ -544,19 +545,19 @@ async def my_async_func(): static_wrapped = staticmethod(my_async_func) # Direct check on descriptor object fails (this is the bug) - assert not asyncio.iscoroutinefunction(static_wrapped) + assert not inspect.iscoroutinefunction(static_wrapped) assert isinstance(static_wrapped, staticmethod) # But unwrapping __func__ reveals the async function unwrapped = static_wrapped.__func__ - assert asyncio.iscoroutinefunction(unwrapped) + assert inspect.iscoroutinefunction(unwrapped) # When accessed via class attribute, Python's descriptor protocol # automatically unwraps it, so it works: class C: async_static = static_wrapped - assert asyncio.iscoroutinefunction(C.async_static) # Works via descriptor protocol + assert inspect.iscoroutinefunction(C.async_static) # Works via descriptor protocol class TestExecutorExplicitTypes: diff --git a/python/packages/devui/tests/devui/test_cleanup_hooks.py b/python/packages/devui/tests/devui/test_cleanup_hooks.py index 8d02bfaf27..7f36f68165 100644 --- a/python/packages/devui/tests/devui/test_cleanup_hooks.py +++ b/python/packages/devui/tests/devui/test_cleanup_hooks.py @@ -3,6 +3,7 @@ """Tests for cleanup hook registration and execution.""" import asyncio +import inspect import tempfile from pathlib import Path @@ -123,7 +124,7 @@ async def test_register_cleanup_multiple_hooks(): # Execute all hooks for hook in hooks: - if asyncio.iscoroutinefunction(hook): + if inspect.iscoroutinefunction(hook): await hook() else: hook() From 589704b99a7f5694317eb77e73a8d18bfcdf6bfa Mon Sep 17 00:00:00 2001 From: Kranthi Manchikanti Date: Mon, 9 Mar 2026 11:57:16 -0400 Subject: [PATCH 2/2] Update python/packages/devui/tests/devui/test_cleanup_hooks.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- python/packages/devui/tests/devui/test_cleanup_hooks.py | 1 - 1 file changed, 1 deletion(-) diff --git a/python/packages/devui/tests/devui/test_cleanup_hooks.py b/python/packages/devui/tests/devui/test_cleanup_hooks.py index 7f36f68165..5336e98d41 100644 --- a/python/packages/devui/tests/devui/test_cleanup_hooks.py +++ b/python/packages/devui/tests/devui/test_cleanup_hooks.py @@ -2,7 +2,6 @@ """Tests for cleanup hook registration and execution.""" -import asyncio import inspect import tempfile from pathlib import Path