Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions python/packages/core/tests/workflow/test_function_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions python/packages/devui/tests/devui/test_cleanup_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

"""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

import tempfile
from pathlib import Path

Expand Down Expand Up @@ -123,7 +123,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()
Expand Down