Skip to content

Hide parameter inlay hint when argument name matches parameter name - #5481

Closed
Aiman-D wants to merge 1 commit into
meta:mainfrom
Aiman-D:fix-5105-inlay-hint-matching-param
Closed

Aiman-D wants to merge 1 commit into
meta:mainfrom
Aiman-D:fix-5105-inlay-hint-matching-param

Conversation

@Aiman-D

@Aiman-D Aiman-D commented Nov 1, 2026

Copy link
Copy Markdown

Summary

Parameter name inlay hints can be redundant when a positional argument is a variable with the exact same name as the parameter. For example, in def foo(a, b): pass, calling foo(a, c) previously displayed hints for both a= and b= .

With this change:

  • Inlay hints are suppressed when the positional argument is a plain name (Expr::Name) matching the parameter name.
  • Non-matching names and complex expressions (such as attribute accesses foo(obj.a, c)) still display their inlay hints.
  • For variadic parameters (Param::Varargs), hints are suppressed when passing a matching starred argument (foo(*args) against *args), but retained when passing an unstarred argument (foo(args)) or a non-matching starred argument (foo(*items)).

Fixes #5105

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

Test Plan

  • Added test_issue_5105_hide_hint_when_arg_matches_param_name in pyrefly/lib/test/lsp/inlay_hint.rs covering:
    • Matching positional arguments suppressed, non-matching shown
    • All arguments matching (no hints shown)
    • Attribute access obj.a retaining hint a=
    • Method calls suppressing matching arguments
    • Positional-only parameters (/)
    • Variadic arguments (*args matching vs non-matching vs unstarred)
    • Starred argument to standard parameter
  • Ran tests:
    • cargo test -p pyrefly --lib test::lsp::inlay_hint (52 passed, 0 failed)
    • cargo test -p pyrefly --lib test::lsp (1404 passed, 0 failed, 3 ignored)
  • Ran pre-commit checks:
    • python3 test.py --no-test --no-tensor-shapes --no-conformance --no-jsonschema --no-extension (fmt and clippy clean)
@meta-cla

meta-cla Bot commented Nov 1, 2026

Copy link
Copy Markdown

Hi @Aiman-D!

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!

@stroxler stroxler left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @Aiman-D!

This looks good to me, but could you rebase once?

Context: we have auto-import hooks for PRs, but they don't run when the initial version goes up before the CLA is signed (because there would be licensing issues with importing).

Usually a rebase will trigger auto-import, which makes it easier to review and merge. I've been meaning to try to improve the tools but haven't found time.

@github-actions

This comment has been minimized.

@Aiman-D
Aiman-D force-pushed the fix-5105-inlay-hint-matching-param branch from 4a5774f to 24fb444 Compare November 1, 2026 17:33
@github-actions github-actions Bot added size/m and removed size/m labels Nov 1, 2026
@meta-cla

meta-cla Bot commented Nov 1, 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 Nov 1, 2026
@meta-cla

meta-cla Bot commented Nov 1, 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!

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

⚠️ Action needed: this PR is missing required items from our pull request checklist:

Note: this comment updates automatically after changes to the PR. Updates may take up to half an hour.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@rchen152

rchen152 commented Nov 1, 2026

Copy link
Copy Markdown
Contributor

Hey there! It looks like #5105 was already claimed by another contributor who has a PR open for it. I realize that we're way behind on PR reviews, which probably made the issue look inactive, but we generally ask that contributors claim issues before starting on them, to help avoid duplicate work.

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Closing this PR because linked issue #5105 was closed.

@github-actions github-actions Bot closed this Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

3 participants