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

Support multiple unused variables #4926

Closed
EvgeniGenchev opened this issue Apr 9, 2023 · 1 comment
Closed

Support multiple unused variables #4926

EvgeniGenchev opened this issue Apr 9, 2023 · 1 comment
Labels
as designed Not a bug, working as intended enhancement request New feature or request

Comments

@EvgeniGenchev
Copy link

Is your feature request related to a problem? Please describe.

When working with functions or classes that require callback functions, I rarely use all the possible arguments that a callback function may provide, which makes for really annoying pyright exceptions about unused varibables. A solution that I use in cases where the I do not need only one argument is putting _ as the name of the unused variable, which is not possible to be done for multiple variables.

image

Describe the solution you'd like
I suggest similarly to pylint to either support multiple underscore notations or underscore + number notations like so:

def function(_, __, ___, _1):
    pass

function(1,2,3,4)

Tested on
nvim 0.9

@EvgeniGenchev EvgeniGenchev added the enhancement request New feature or request label Apr 9, 2023
@erictraut
Copy link
Collaborator

erictraut commented Apr 9, 2023

Pyright never generates diagnostics for unused function parameters. It only generates hints with a tag that tells an editor to display the text in a greyed-out manner. Neovim has chosen to request this hint from a language server but then display it as a normal diagnostic. I've tried to get the neovim maintainers to change the behavior, but they are not convinced. See this issue for details.

I recommend that you configure neovim not to display any "hints". Hints with the "Unnecessary code" tag are not intended to be displayed as diagnostics, and other editors (like VS Code) do not display them as such.

In any case, pyright is working as designed here.

@erictraut erictraut added the as designed Not a bug, working as intended label Apr 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
as designed Not a bug, working as intended enhancement request New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants