Skip to content

Inlay hint suppress matching name - #5287

Open
La1itchauhan wants to merge 2 commits into
facebook:mainfrom
La1itchauhan:inlay-hint-suppress-matching-name
Open

La1itchauhan wants to merge 2 commits into
facebook:mainfrom
La1itchauhan:inlay-hint-suppress-matching-name

Conversation

@La1itchauhan

Copy link
Copy Markdown

Summary

Parameter name inlay hints are redundant when a positional argument is a bare variable with the same name as its parameter. For def foo(a, b), calling foo(a, c) previously displayed hints for both a= and b=. It now shows only b=.

The hint is skipped when the argument is a plain name (Expr::Name) identical to the parameter name. Other expressions, such as attribute accesses (obj.a), still receive hints.

Design note: for *args, calling foo(args) against def foo(*args) also hides the hint since the names match.

Fixes #5105

  • I am a human, and I fully understand the code I am submitting.

AI disclosure: I used an AI assistant in an agentic coding environment to explore the codebase and draft the initial patch and unit tests. The assistant ran build, format, and git commands in WSL under my direction. I reviewed and verified the implementation, commit structure, and test results myself.

Test Plan

  • Added test_issue_5105_hide_hint_when_arg_matches_param_name in pyrefly/lib/test/lsp/inlay_hint.rs, covering:
    • Matching argument name (hidden) alongside non-matching name (shown).
    • All arguments matching parameters (all hints suppressed).
    • Attribute access obj.a against parameter a (still shown).
  • Confirmed the new test fails without the fix and passes with it.
  • cargo test inlay_hint: all inlay hint tests pass except test_constructor_inlay_hint, which fails identically on clean upstream/main in my local WSL setup (list[Unknown] vs list[int]).
  • Pre-commit check python3 test.py --no-test --no-tensor-shapes --no-conformance --no-jsonschema --no-extension (rustfmt and clippy) passes with exit code 0.
  • Relying on CI for the clean-environment full test suite.

When an argument is a bare variable named the same as its parameter,
the hint repeats what the code already says. These tests cover that
case, a different-name argument that still gets a hint, and an
attribute access like obj.a, which is not treated as a match.
Showing `a=` before an argument that is already named `a` is noise.
Skip the hint when a positional argument is a plain name identical to
its parameter's name. Other expressions, including attribute
accesses, still get hints.

Fixes facebook#5105
@meta-cla

meta-cla Bot commented Oct 19, 2026

Copy link
Copy Markdown

Hi @La1itchauhan!

Thank you for your pull request and welcome to our community.

Action Required

In order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you.

Process

In order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA.

Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@meta-cla

meta-cla Bot commented Oct 19, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

@meta-cla meta-cla Bot added the cla signed label Oct 19, 2026
@meta-cla

meta-cla Bot commented Oct 19, 2026

Copy link
Copy Markdown

Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks!

This branch has not been deployed

No deployments
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.

hide inlay hint when name is the same

2 participants