-
Notifications
You must be signed in to change notification settings - Fork 182
fix Feat: Expand **kwargs with field names on hover when **kwargs is typed with Unpack (i.e. **kwargs: Unpack[T]) #758 #1514
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
| if let Some(fields) = collect_typed_dict_fields_for_hover(solver, ty) { | ||
| changed = true; | ||
| for (field_name, field_type, required) in fields { | ||
| expanded.push(Param::KwOnly(field_name, field_type, required)); |
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.
Since required parameters can't come after non-required ones (there isn't a type checking issue here, just looks weird when we display it), we'd probably want to put the required TypedDict fields ahead of any non-required parameters. After the list is expanded, we can partition expanded by required-ness to make the new list.
yangdanny97
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.
Rest of it LGTM, just the parameter sorting issue
|
@yangdanny97 has imported this pull request. If you are a Meta employee, you can view this in D86638374. |
kinto0
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.
Review automatically exported from Phabricator review in Meta.
|
@yangdanny97 merged this pull request in 165ee55. |
fix #758
Hover output now expands **kwargs typed with typing.Unpack[TypedDict] into their constituent keyword-only parameters so people hovering a call see the real argument names.
Implemented the expansion by letting HoverValue accept a pre-computed display string, formatting callables via transaction.ad_hoc_solve, and inserting typed-dict fields as synthetic Param::KwOnly entries before the original **kwargs.