enekoreto opened a new pull request, #1054:
URL: https://github.com/apache/burr/pull/1054

   `@action.pydantic` checks the `state` and return annotations with 
`issubclass`, which raises `TypeError: issubclass() arg 1 must be a class` when 
the annotation isn't a class, for example `Optional[Model]`, `Model | None`, 
`Union[Model, int]` or `List[Model]`. So instead of the usual "is not a valid 
pydantic action" message, you get a bare `TypeError` that doesn't say which 
function it was.
   
   ## Changes
   
   - `_validate_and_extract_signature_types`: check `isinstance(..., type)` 
before both `issubclass` calls, so these annotations get the same `ValueError` 
as any other wrong type. Correct annotations are unchanged.
   - Three new cases in `test__validate_and_extract_signature_types_error`: an 
`Optional` state, an `Optional` return and a `List` return. They also run 
through `test_burr_pydantic_future_annotations.py`.
   
   ## How I tested this
   
   - The 6 new test cases fail on main with the `TypeError` and pass here, on 
Python 3.13 and 3.10.
   - I also tried `Model | None`, `Union[Model, int]` and `list[Model]` returns 
by hand: all now raise the `ValueError`. On 3.10, `list[Model]` already did.
   - Full test suite and pre-commit pass, on Python 3.13 and 3.10.
   
   ## Notes
   
   I noticed this while reviewing #1013, which fixes the text of these two 
messages (the return-type one still shows `{sig.return_annotation}` on main). 
The two PRs touch nearby lines but merge cleanly, and the suite passes with 
both applied.
   
   This was done with AI assistance (Claude Code), and checked by running the 
tests described above.
   
   ## Checklist
   
   - [x] PR has an informative and human-readable title (this will be pulled 
into the release notes)
   - [x] Changes are limited to a single goal (no scope creep)
   - [x] Code passed the pre-commit check & code is left cleaner/nicer than 
when first encountered.
   - [x] Any _change_ in functionality is tested
   - [ ] New functions are documented (with a description, list of inputs, and 
expected output)
   - [ ] Placeholder code is flagged / future TODOs are captured in comments
   - [ ] Project documentation has been updated if adding/changing 
functionality.
   


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