Skip to content

fix: allow union types in streaming_action.pydantic stream_type parameter#732

Open
mvanhorn wants to merge 1 commit intoapache:mainfrom
mvanhorn:fix/stream-type-union-support
Open

fix: allow union types in streaming_action.pydantic stream_type parameter#732
mvanhorn wants to merge 1 commit intoapache:mainfrom
mvanhorn:fix/stream-type-union-support

Conversation

@mvanhorn
Copy link
Copy Markdown

@mvanhorn mvanhorn commented Apr 8, 2026

Python 3.10+ union syntax (MyModel1 | MyModel2) creates a types.UnionType, which the stream_type parameter rejected because it only accepted Type[BaseModel] or Type[dict].

Added types.UnionType to the accepted types in three places:

  • burr/integrations/pydantic.py: PartialType alias (line 272)
  • burr/integrations/pydantic.py: _validate_and_extract_signature_types_streaming parameter (line 293)
  • burr/core/action.py: streaming_action.pydantic parameter (line 1514)

Before:

stream_type=MyModel1 | MyModel2  # TypeError

After:

stream_type=MyModel1 | MyModel2  # works

Both files already import types, so no new imports needed. types.UnionType is available in Python 3.10+; on 3.9, the | syntax isn't available anyway so the added type is inert.

Fixes #607

This contribution was developed with AI assistance (Claude Code).

…eter

Accept types.UnionType in stream_type so Python 3.10+ union syntax
(MyModel1 | MyModel2) works with streaming_action.pydantic decorator.

Fixes apache#607
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Streaming Event type, type hint, should support union type

1 participant