Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't put noise in the scrollbar for unused function arguments named __ in Python #7907

Closed
vsfeedback opened this issue May 21, 2024 · 2 comments
Assignees

Comments

@vsfeedback
Copy link

This issue has been moved from a ticket on Developer Community.


This code makes Visual Studio complain that the variable function arguments __ is unused. I think it should work like _. Because _ don't create noise in the scrollbar. When I

from my_module import default_kafka_function

def wrapper_kafka_function(*_, **__):
    default_kafka_function()

image.png

Alternatively I would be happy if this did not create noise in the scrollbar.

from my_module import default_kafka_function

def wrapper_kafka_function(*args, **kwargs):
        default_kafka_function()

Original Comments

Feedback Bot on 5/6/2024, 08:42 PM:

(private comment, text removed)

@StellaHuang95
Copy link
Contributor

Put in the triage to discussion with the team.

  1. Is it expected that the diagnostics show up on hover with reportUnusedXXX set to false?
    image

  2. I can repro it with a simple functioin
    image

@StellaHuang95
Copy link
Contributor

Thank you for reaching out about the diagnostic hints you are seeing in PTVS.

The behavior you described, where xxx is not accessed hints appear on hover, is by design. This also applies to kwargs. PTVS utilizes Pylance as its language server to provide these diagnostic features.

Using an underscore (_) as a parameter name is a common and accepted practice to indicate that a value will not be used. Therefore, Pylance recognizes _ as a deliberate choice and does not report it as unused.

The diagnostic hints displayed on hover by Pylance are intentional, and there is no way to disable this through PTVS. If you would like to suggest a change or look for a way to turn off these hints, we recommend proposing this feature on the Pylance GitHub repository at https://github.com/microsoft/pylance-release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants