-
Notifications
You must be signed in to change notification settings - Fork 3k
fix: wrapped annotations handling in func_metadata #1392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
maxisbey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of any custom forward reference resolving code, just use get_type_hints from https://docs.python.org/3/library/typing.html#typing.get_type_hints
As was done here: https://github.com/modelcontextprotocol/python-sdk/pull/1286/files#diff-4a929a2d33aa16d96d544463138bab06b115bd9653dcdb842d94508c8b30a6cd
|
Thanks @maxisbey will do that. |
66290b6 to
088335d
Compare
Use the original function's __globals__ for type hint resolution when dealing with wrapped functions. This ensures that any type hints defined in the original function's module are correctly resolved. This also includes adding common typing names for resiliency. Fixes modelcontextprotocol#1391
088335d to
57fe5ba
Compare
|
Is this what you had in mind @maxisbey ? |
Hmm actually I was thinking that to avoid having to eval stuff. But, I now realise that also calls |
|
Closing due to inactivity. |
|
I can only guess this is a bot? |
|
Sorry for the confusion, I'm not a bot! Was just running through all the old PRs with Claude Code to close as many stale ones as we could to make the queue a bit more manageable before the holidays. If you're wanting to continue this then please feel free to re-open it and make the changes I suggested above and rebase onto main. |
Use the original function's globals for type hint resolution when dealing with wrapped functions. This ensures that any type hints defined in the original function's module are correctly resolved.
This also includes adding common typing names for resiliency.
Fixes #1391
Motivation and Context
Fixes tool handling for wrapped methods that use annotations.
How Has This Been Tested?
Test is included.
Breaking Changes
This should be fully backwards compatible.
Types of changes
Checklist
Additional context
Tries to ensure success even if standard typing types are missing.