mirakour commented on PR #845:
URL: https://github.com/apache/burr/pull/845#issuecomment-5124366117

   Thanks for the thorough review, @eeshsaxena, and especially for catching 
that my original tests passed against unmodified `main`. You're right that they 
weren't guarding anything, since 
`_validate_and_extract_signature_types_streaming` never actually inspected 
`stream_type`.
   
   I've pushed three commits that address the feedback:
   
   1. **Real validation at decoration time.** Added `_is_valid_stream_type()` 
in `burr/integrations/pydantic.py` and wired it into 
`_validate_and_extract_signature_types_streaming`. It accepts a 
`pydantic.BaseModel` subclass, `dict` (or a `dict` subclass), or a union of 
those, and recurses into the union members, so an invalid member (e.g. `ModelA 
| int`) or a non-type like `int` now raises a `ValueError` at decoration time 
instead of slipping through. That also addresses the per-member question from 
#607 (each member is checked individually rather than assuming they're all the 
same).
   
   2. **Both union spellings.** Detection keys on `typing.get_origin(...) is 
typing.Union` as well as `types.UnionType`, so `typing.Union[A, B]` is handled 
alongside the PEP 604 `A | B` form on 3.10+ (and `typing.Union` works on 3.9 
too).
   
   3. **Meaningful annotation.** Replaced the `Union[..., Any]` in `action.py` 
(which collapsed to plain `Any`) with a `types.UnionType` forward reference so 
the hint stays informative.
   
   4. **Tests that actually guard.** Added tests asserting that invalid unions 
and non-model/non-dict stream types are *rejected*, which fail on unmodified 
`main`, plus acceptance tests for both `typing.Union` and `A | B`.
   
   On the overlap with #813: totally fair, and I'll defer to the maintainers on 
which approach to take. Happy to fold in anything from that PR or iterate 
further based on your review.
   


-- 
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]

Reply via email to