question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handling 'unused parameter' hints

See original GitHub issue

Pyright flags unused function parameters with a hint.

Screen Shot 2020-10-24 at 12 11 12 PM

That is often helpful, but when you’re trying to satisfy some library’s API, you may want to include placeholders for parameters even if a function or method doesn’t actually use them. An unused argument warning can be silenced by naming a parameter _, but that only works for one parameter. Names can be dundered (like __name__), but that feels like a hack, and doesn’t work for keyword parameters. You could also use *arg and **kwargs, but is a bit less clear that having placeholders.

According to this, the Pyright language server tags unused parameter hints in some way, and the LSP client can tell Pyright that it doesn’t support this tag to prevent Pyright from sending these hints. Possibly coc-pyright could provide an option to disable unused argument hints.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
fannheywardcommented, Oct 30, 2020

Fixed in https://github.com/neoclide/coc.nvim/pull/2538, upgrade to latest coc.nvim and set diagnostic.showUnused to false.

1reaction
lucatpacommented, Jul 28, 2021

I’m caught in the middle of different opinions here, because pyright developers say this should only be a syntax highlight hint and no other visual indication should be shown. For parameters of functions that are fulfilling some API this leaves users in a bad position where they have to chose to have visual noise for irrelevant (and unavoidable) noise (having a popup and a mark in the line) or completely disabling all unused variables hinting.

So is there no way to reconcile both projects views on this one? Should I just give up? And I’m not being cynical here, I’m truly hugely thankful to both projects because they make my life so much easier, this is only a tiny nuance. I just want to avoid wasting your and my time if there will be no agreement between both projects.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Best way to handle unused function arguments - Stack Overflow
Best way to handle unused function arguments ; 2. It's perfectly fine in contexts like this. – Barmar ; 1. Best in terms...
Read more >
Unused values and parameters - Visual Studio (Windows)
Learn about unused value assignments, variables, and parameters and how they appear in the code editor in Visual Studio.
Read more >
Unused parameters in a function. Best way to express it?
1. ommit parameter name void func(int) { }. 2. old-style cast to void void func(int unused) { (void) unused; // remove space or...
Read more >
solidity - Unused function parameter. Remove or comment out ...
There is a curious feature that if you remove the variable name the warning disappears. But the function still has the same signature....
Read more >
C++ static code analysis: Unused function parameters should ...
Unused parameters are misleading. Whatever the values passed to such parameters, the behavior will be the same. There are some cases when you...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found