Files
semantic-kernel/python/tests
kanchi cef5ae7402 Python: Support | and |= operators for KernelArgument (#12499)
### 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

<!-- 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
- [x] I didn't break anyone 😄
2025-06-19 07:24:16 +00:00
..
2023-04-13 16:12:36 -07:00