Repository navigation
Inlay hint suppress matching name - #5287
La1itchauhan wants to merge 2 commits into
Conversation
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
|
Hi @La1itchauhan! Thank you for your pull request and welcome to our community. Action RequiredIn 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. ProcessIn 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 If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
|
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Meta Open Source project. Thanks! |
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), callingfoo(a, c)previously displayed hints for botha=andb=. It now shows onlyb=.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, callingfoo(args)againstdef foo(*args)also hides the hint since the names match.Fixes #5105
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
test_issue_5105_hide_hint_when_arg_matches_param_nameinpyrefly/lib/test/lsp/inlay_hint.rs, covering:obj.aagainst parametera(still shown).cargo test inlay_hint: all inlay hint tests pass excepttest_constructor_inlay_hint, which fails identically on cleanupstream/mainin my local WSL setup (list[Unknown]vslist[int]).python3 test.py --no-test --no-tensor-shapes --no-conformance --no-jsonschema --no-extension(rustfmt and clippy) passes with exit code 0.