Skip to content

Conversation

@asukaminato0721
Copy link
Contributor

fix part of #317

Type pretty-printing now tracks every module name it emits, so we can tell the client which imports a hint depends on; TypeDisplayContext stores the module set in a RefCell, exposes it via referenced_modules, and records each module.name combination as it formats the text

The LSP transaction layer wraps each hint in a new InlayHintWithEdits struct, renders annotations with fully qualified names, applies any local aliases (e.g., import typing as t), and bundles the necessary import edits by consulting the ImportTracker. This ensures that accepting a type hint also inserts import typing when the module hasn’t been brought into scope.

Downstream consumers now understand the richer hint payload: the server translates InlayHintWithEdits into multiple textEdits, the playground/WASM bindings expose the new label format, and the inlay-hint regression tests cover both standard and notebook scenarios to verify the extra import edits.

Copy link
Contributor

@kinto0 kinto0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awesome work! a few suggestions + it looks like there are some merge conflicts. it might also be worth coordinating with @jvansch1 over discord to make sure you're not stepping on each other's toes since he's editing the same file

result: Some(serde_json::json!([
{
"label":" -> tuple[Literal[1], Literal[2]]",
"label":" -> tuple[typing.Literal[1], typing.Literal[2]]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @jvansch1 as you are also currently making changes to this

Copy link
Contributor

@kinto0 kinto0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like the insertion text no longer matches the type

"label":" -> tuple[Literal[1], Literal[2]]",
"position":{"character":21,"line":6},
"textEdits":[{
"newText":" -> tuple[Literal[1], Literal[2]]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"newText":" -> tuple[Literal[1], Literal[2]]",
"newText":" -> tuple[typing.Literal[1], typing.Literal[2]]",

if we import typing, we need to qualify these types with it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is still an issue

@kinto0 kinto0 removed their assignment Nov 20, 2025
@jvansch1 jvansch1 removed their assignment Nov 20, 2025
"label":" -> tuple[Literal[1], Literal[2]]",
"position":{"character":21,"line":6},
"textEdits":[{
"newText":" -> tuple[Literal[1], Literal[2]]",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is still an issue

@asukaminato0721 asukaminato0721 marked this pull request as draft November 22, 2025 06:06
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.

3 participants