-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Properly fetch PEP 695 type params for functions, do not fetch annotations from signature #11093
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
@@ -123,7 +125,11 @@ def ns_for_function(obj: Callable[..., Any], parent_namespace: MappingNamespace | |||
# passed as a separate argument. However, internally, `_eval_type` calls | |||
# `ForwardRef._evaluate` which will merge type params with the localns, | |||
# essentially mimicking what we do here. | |||
type_params: tuple[TypeVar, ...] = () |
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.
I somehow forgot to actually fetch the type params here 🤔
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.
Turns out the test did not use forward annotations, so it was fixed as well.
CodSpeed Performance ReportMerging #11093 will not alter performanceComparing Summary
|
d78f8b0
to
80251eb
Compare
Deploying pydantic-docs with
|
Latest commit: |
61e935d
|
Status: | ✅ Deploy successful! |
Preview URL: | https://d47ea3e5.pydantic-docs.pages.dev |
Branch Preview URL: | https://validate-call-fixes.pydantic-docs.pages.dev |
…tions from signature We now unsupport built-in functions.
80251eb
to
61e935d
Compare
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
1 similar comment
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
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.
Looking good overall, added a few follow up questions. Thanks!
@@ -1832,13 +1832,7 @@ def _call_schema(self, function: ValidateCallSupportedTypes) -> core_schema.Call | |||
if p.annotation is sig.empty: | |||
annotation = typing.cast(Any, Any) | |||
else: | |||
# Note: This was originally get by `_typing_extra.get_function_type_hints`, | |||
# but we switch to simply `p.annotation` to support bultins (e.g. `sorted`). | |||
# May need to revisit if anything breaks. |
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.
Haha, yikes.
Fixes #11076, fixes #11073.
Turns out discussion in #10484 (comment) was relevant, as not using
get_function_type_hints
would skip theNone -> NoneType
conversion, and other things might happen as well.Change Summary
Related issue number
Checklist