mirror of
https://github.com/microsoft/semantic-kernel.git
synced 2026-10-12 02:19:06 +00:00
### Motivation and Context <!-- Thank you for your contribution to the semantic-kernel repo! Please help reviewers and future users, providing the following information: 1. Why is this change required? 2. What problem does it solve? 3. What scenario does it contribute to? 4. If it fixes an open issue, please link to the issue here. --> This solves [this issue](https://github.com/microsoft/semantic-kernel/issues/1069) where native functions are not returning the expected result. In python, return typehints are optional. However, the semantic kernel requires a return typehint to determine how to handle the function. For that reason, we're now enforcing return typehints and raising an exception when one is not provided. This may break existing void functions but none in our repo are affected. Fixes #1069 ### Description <!-- Describe your changes, the overall approach, the underlying design. These notes will help understanding how your code works. Thanks! --> ### Contribution Checklist <!-- Before submitting this PR, please make sure: --> - [x] The code builds clean without any errors or warnings - [x] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [x] All unit tests pass, and I have added new tests where possible - [] I didn't break anyone 😄 ## Summary This pull request includes two sets of changes. First, it fixes the return type annotations in three core skills: file_io_skill, text_memory_skill, and wait_skill. Specifically, the write_async method in file_io_skill and the save_async method in text_memory_skill now have a return type of None, and the wait method in wait_skill now has a return type of None. Additionally, the import_native_skill_from_directory method in kernel.py has been refactored to simplify the code. Second, this pull request adds error handling for functions with no return type in the delegate inference module. Previously, if a function did not specify a return type, the DelegateType could not be inferred, leading to errors. This pull request adds a check for functions with no return type and raises a KernelException with an appropriate error message. Additionally, this pull request includes some minor changes to unit tests for native functions. ## Changes - Fixed return type annotation for write_async method in file_io_skill - Fixed return type annotation for save_async method in text_memory_skill - Fixed return type annotation for wait method in wait_skill - Refactored import_native_skill_from_directory method in kernel.py - Added error handling for functions with no return type in the delegate inference module - Added a check for functions with no return type and raised a KernelException with an appropriate error message - Made minor changes to unit tests for native functions --- *Powered by [Microsoft Semantic Kernel](https://github.com/microsoft/semantic-kernel)*