Skip to content

Conversation

@majiayu000
Copy link
Contributor

@majiayu000 majiayu000 commented Dec 31, 2025

Summary

  • treat union type objects as valid stream_type values for pydantic streaming actions
  • keep runtime behavior unchanged while relaxing type hints for union-type streams

Testing

  • not run (type-hint only change)

Comment on lines +70 to +75
if typing.TYPE_CHECKING:
StreamingPydanticType = Any
else:
StreamingPydanticType = Union[Type["BaseModel"], Type[dict]]
if UnionType is not None:
StreamingPydanticType = Union[Type["BaseModel"], Type[dict], UnionType]
Copy link
Contributor

@skrawcz skrawcz Jan 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doing Any for typing checking will of course work and is cheating...

I think we shouldn't have a typing.TYPE_CHECKING part here, and instead I think the fix is line 74 + 75.

note I had to do this stream_type: Union[Type["BaseModel"], Type[dict], type, "types.UnionType"], for my pyright in the IDE to not complain -- i.e. the quotes part.

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.

2 participants