1

I use VS Code and the unused parameters of functions are only greyed out, but never reported.

How to report those greyed out warning in the problem explorer?

Currently, thanks to the parameter reportUnusedVariable in pyright, we can report unused variables, but we cannot report unused parameters.

Lajos Arpad
  • 64,414
  • 37
  • 100
  • 175
  • There is no relevant function at present https://github.com/microsoft/pyright/issues/3473 https://github.com/microsoft/pylance-release/issues/2875 – MingJie-MSFT Jun 01 '22 at 01:07

1 Answers1

2

If you're using Pylance or Pyright, seems like you can't mark unused parameters as errors. They're not always errors - sometimes you need them to conform to some interface.

If you want to prohibit unused parameters anyway, there are other tools such as the flake8-unused-arguments plugin for flake8.

decorator-factory
  • 2,733
  • 13
  • 25
  • Thanks, yeah, it's impossible in pyright. And it seems it's a bit more complicated than I thought so I do not think it will be implmented in pyright soon, so flake8-unused-arguments plugin is the way to go even if this library is still incomplete – Charbel-Raphaël Segerie May 19 '22 at 17:56
  • I'm commenting here to say that flake8-unused-arguments has been very useful during the last days. It requires spending some time to choose the right parameters, but overall very good. I now understand why it's not by default in pylance because it's not trivial to setup correctly. – Charbel-Raphaël Segerie Jun 01 '22 at 22:18