Skip to content

Python: Support | and |= operators for KernelArgument #12499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

KanchiShimono
Copy link
Contributor

Motivation and Context

KernelArguments extends the built-in dict by adding an execution_settings attribute.
However, when using the | and |= operators, only the dict part (excluding execution_settings) is merged, and the result becomes a plain dict.
This causes the execution_settings attribute to be lost and not updated.

Description

  • Implemented support for the | and |= operators to make it easier for users to merge KernelArgument objects.
  • The right-hand or left-hand side of the operator can be either a KernelArgument or a dict (or any subclass of dict).
  • When merging, both the execution_settings attribute and the rest of the dict data are merged individually, and the result is returned as a KernelArgument.
  • As long as either side of the operator is a KernelArgument, the result will also be a KernelArgument.

Contribution Checklist

@KanchiShimono KanchiShimono requested a review from a team as a code owner June 17, 2025 02:15
@markwallace-microsoft markwallace-microsoft added the python Pull requests for the Python Semantic Kernel label Jun 17, 2025
@github-actions github-actions bot changed the title Support | and |= operators for KernelArgument Python: Support | and |= operators for KernelArgument Jun 17, 2025
@markwallace-microsoft
Copy link
Member

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
functions
   kernel_arguments.py41295%87, 103
TOTAL26450395185% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3652 22 💤 0 ❌ 0 🔥 2m 8s ⏱️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
python Pull requests for the Python Semantic Kernel
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants