Ghraven opened a new pull request, #754:
URL: https://github.com/apache/burr/pull/754
Fixes #607
## What
Broadens the `stream_type` parameter type annotation in
`streaming_action.pydantic()` and `pydantic_streaming_action()` to accept a
union of pydantic `BaseModel` types in addition to a single `Type[BaseModel]`
or `Type[dict]`.
## Why
Users who pass a union of models (e.g. `MyModel1 | MyModel2`) hit a static
type error at the call site because the parameter was typed as
`Union[Type[BaseModel], Type[dict]]`, which only accepts a single concrete
model type. The runtime validation logic in
`_validate_and_extract_signature_types_streaming()` already handles union types
correctly — this was a type annotation gap only.
## Changes
- `burr/core/action.py`: `stream_type` parameter in
`streaming_action.pydantic()` widened to accept `object` (covers union types,
which are not expressible as `Type[X]`).
- `burr/integrations/pydantic.py`: Same change to `PartialType` alias and
the validator function signature.
- Docstring updated to mention union support.
## Testing
No behaviour change — this is a type annotation fix only. Existing tests
continue to pass. Users can now write:
```python
union = MyModel1 | MyModel2
@streaming_action.pydantic(
reads=[...],
writes=[...],
state_input_type=...,
state_output_type=...,
stream_type=union,
)
```
without a type error.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]