fix: allow union types in streaming_action.pydantic stream_type parameter#732
fix: allow union types in streaming_action.pydantic stream_type parameter#732mvanhorn wants to merge 1 commit intoapache:mainfrom
Conversation
…eter Accept types.UnionType in stream_type so Python 3.10+ union syntax (MyModel1 | MyModel2) works with streaming_action.pydantic decorator. Fixes apache#607
|
Thanks! Can you validate that pyright doesn't complain? That's the litmus test here. |
|
Ran pyright (1.1.408) against the two changed files and compared to main:
No new pyright issues introduced by the |
|
@mvanhorn all the test failures are related to this change. can you run the unit tests locally please?
Otherwise, can you create an example that has:
and that pyright doesn't complain about? |
Python 3.10+ union syntax (
MyModel1 | MyModel2) creates atypes.UnionType, which thestream_typeparameter rejected because it only acceptedType[BaseModel]orType[dict].Added
types.UnionTypeto the accepted types in three places:burr/integrations/pydantic.py:PartialTypealias (line 272)burr/integrations/pydantic.py:_validate_and_extract_signature_types_streamingparameter (line 293)burr/core/action.py:streaming_action.pydanticparameter (line 1514)Before:
After:
Both files already import
types, so no new imports needed.types.UnionTypeis 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).