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
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def _parse_parameter(name: str, param: Any, default: Any) -> dict[str, Any]:
if isinstance(meta, str):
ret["description"] = meta
elif isinstance(meta, dict):
meta = meta.copy()
# only override from the metadata if it is not already set
if "description" not in ret and (description := meta.pop("description", None)):
ret["description"] = description
Expand Down
16 changes: 16 additions & 0 deletions python/tests/unit/functions/test_kernel_function_decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,22 @@ def test_kernel_function_param_annotated():
assert my_func.__kernel_function_parameters__[0]["name"] == "input"


def test_kernel_function_does_not_mutate_shared_annotated_metadata():
shared = {"description": "the answer count"}

@kernel_function
def first(value: Annotated[int, shared]) -> int:
return value

@kernel_function
def second(value: Annotated[int, shared]) -> int:
return value

assert shared == {"description": "the answer count"}
assert first.__kernel_function_parameters__[0]["description"] == "the answer count"
assert second.__kernel_function_parameters__[0]["description"] == "the answer count"


def test_kernel_function_param_optional():
decorator_test = MiscClass()
my_func = getattr(decorator_test, "func_input_optional")
Expand Down
Loading