Skip to content

Commit 1b95227

Browse files
joowon-dm-snudluc
authored andcommitted
fix: static functions has no attr __wrapped__ (microsoft#169)
### Motivation and Context 1. Why is this change required? `pytest .` raises error 2. What problem does it solve? pass all test 3. What scenario does it contribute to? `infer_delegate_type` will not raise error 4. If it fixes an open issue, please link to the issue here. microsoft#168 ### Description static function has no attribute __wrapped__ and this raises error. use __func__ for this. I think `wrapped = getattr(value, "__wrapped__", getattr(value, "__func__", None))` is reasonable for this issue. ```@staticmethod def infer_delegate_type(function) -> DelegateTypes: # Get the function signature function_signature = signature(function) awaitable = iscoroutinefunction(function) for name, value in DelegateInference.__dict__.items(): if name.startswith("infer_") and hasattr( > value.__wrapped__, "_delegate_type" ): E AttributeError: 'staticmethod' object has no attribute '__wrapped__' ../semantic_kernel/orchestration/delegate_inference.py:240: AttributeError ======================================================================================= short test summary info ======================================================================================= FAILED test_text_skill.py::test_can_be_imported - AttributeError: 'staticmethod' object has no attribute '__wrapped__' FAILED test_text_skill.py::test_can_be_imported_with_name - AttributeError: 'staticmethod' object has no attribute '__wrapped__' ===================================================================================== 2 failed, 9 passed in 0.23s ===================================================================================== ```
1 parent 3034075 commit 1b95227

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

python/semantic_kernel/orchestration/delegate_inference.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -236,11 +236,11 @@ def infer_delegate_type(function) -> DelegateTypes:
236236
awaitable = iscoroutinefunction(function)
237237

238238
for name, value in DelegateInference.__dict__.items():
239-
if name.startswith("infer_") and hasattr(
240-
value.__wrapped__, "_delegate_type"
241-
):
239+
wrapped = getattr(value, "__wrapped__", getattr(value, "__func__", None))
240+
241+
if name.startswith("infer_") and hasattr(wrapped, "_delegate_type"):
242242
# Get the delegate type
243-
if value.__wrapped__(function_signature, awaitable):
244-
return value.__wrapped__._delegate_type
243+
if wrapped(function_signature, awaitable):
244+
return wrapped._delegate_type
245245

246246
return DelegateTypes.Unknown

0 commit comments

Comments
 (0)