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

   If `@action.pydantic` is applied to a function with a bad signature, the 
`ValueError` shows literal `{sig}` / `{sig.return_annotation}` text instead of 
the real signature. Two lines of the message in 
`_validate_and_extract_signature_types` were missing the `f` prefix.
   
   Before:
   ```
   ValueError: Function fn: _fn_without_state_arg is not a valid pydantic 
action. The first argument of a pydantic action must be the state object. Got 
signature: {sig}.
   ```
   After:
   ```
   ValueError: Function fn: _fn_without_state_arg is not a valid pydantic 
action. The first argument of a pydantic action must be the state object. Got 
signature: (foo: tests.integrations.test_burr_pydantic.OriginalModel) -> 
tests.integrations.test_burr_pydantic.OriginalModel.
   ```
   
   ## Changes
   
   - `burr/integrations/pydantic.py`: add the missing `f` prefix to the "Got 
signature" message.
   - The return-type message now prints the resolved type hint (`ret_hint`) 
rather than `sig.return_annotation`. With `from __future__ import annotations`, 
`sig.return_annotation` is only the string `'int'`, while `ret_hint` is the 
real type the check ran against.
   - `tests/integrations/test_burr_pydantic.py`: two regression tests check 
both messages. They also run under `test_burr_pydantic_future_annotations.py`.
   
   ## How I tested this
   
   - `pytest tests/integrations/test_burr_pydantic.py 
tests/integrations/test_burr_pydantic_future_annotations.py`: 72 passed. 
Without the source change, the 4 new test cases fail.
   - `pre-commit run` on the changed files (black, isort, flake8, ASF headers) 
passes.
   
   ## Notes
   
   I found this while reading the code; there is no issue for it. I used an AI 
assistant to help prepare the change, then reviewed and tested it myself.
   
   ## 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) (no new functions)
   - [ ] Placeholder code is flagged / future TODOs are captured in comments 
(n/a)
   - [ ] Project documentation has been updated if adding/changing 
functionality. (n/a)
   


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