Skip to content

Conversation

@asukaminato0721
Copy link
Contributor

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.

@meta-cla meta-cla bot added the cla signed label Nov 6, 2025
@asukaminato0721 asukaminato0721 marked this pull request as ready for review November 6, 2025 14:01
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));
Copy link
Contributor

@yangdanny97 yangdanny97 Nov 6, 2025

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.

Copy link
Contributor

@yangdanny97 yangdanny97 left a 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 yangdanny97 self-assigned this Nov 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feat: Expand **kwargs with field names on hover when **kwargs is typed with Unpack (i.e. **kwargs: Unpack[T])

2 participants