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
Use __wrapped__ attribute #5077
base: master
Are you sure you want to change the base?
Use __wrapped__ attribute #5077
Conversation
📝 Docs preview for commit cd17a8c at: https://62b5f83b3b5ee400907caa09--fastapi.netlify.app |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5077 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 540 541 +1
Lines 13969 13930 -39
=========================================
- Hits 13969 13930 -39 ☔ View full report in Codecov by Sentry. |
…ped__ attribute. It is guarded by a hasattr check, so it is safe to ignore this error.
📝 Docs preview for commit c1691f5 at: https://62b5fdb2c1e6e8008a527e31--fastapi.netlify.app |
📝 Docs preview for commit c3591b3 at: https://62b60a4cf0eaae00569dd8dd--fastapi.netlify.app |
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.
Very nice, agree with the solution and good work on providing a testcase with proper docstring explaining the issue at hand.
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.
LGTM. I have one small suggestion
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.
LGTM ⚡️
Co-authored-by: Yurii Karabas <1998uriyyo@gmail.com>
📝 Docs preview for commit f412d36 at: https://62b8a0e96d2aa16e090cb5d7--fastapi.netlify.app |
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.
LGTM
@tiangolo This PR has 3 approvals. Could you please merge this PR or comment about what additional steps I should take prior to merge? Thanks! |
📝 Docs preview for commit d293bb3 at: https://6317df3295a60f20eaf20f2e--fastapi.netlify.app |
+1 I'd love for this to merge in! |
@tiangolo what would it take to get this merged in? |
@tiangolo following up again -- pr has 3 approvals, what can we do to get this in? |
@tiangolo Would it be possible to get this merged? |
📝 Docs preview for commit c1f1585 at: https://63901889b9f3e837ecb3eca9--fastapi.netlify.app |
@tiangolo is there anything is particular that is blocking this PR from merging? |
@tiangolo hey! is there any way for me to help prioritize this getting in? FWIW post 0.89 you also need to update get_typed_return_annotation to look like this:
|
Fixes #5065 where the
globalns
computation inget_typed_signature
misses an edge case handled bytyping.get_type_hints
. This PR makes the logic similar toget_type_hints
.Background
functools.wraps
updates the annotations and type signature to match the wrapped function. However, it copies the__annotations__
dict verbatim, including forward references (strings).get_type_hints
handles this by dereferencing the__wrapped__
attribute until it gets to the original function, then uses the__globals__
of that function.Testing
I added a test case which reproduced the
NameError
seen in #5065. The test passes after my commit updating the implementation ofget_typed_signature
: