Parameter 'kwargs' value is not used - unused local - option for function/method parameters

Answered

Hi

I find inspections very useful, unfortunately quiet often I've got warnings where some parameters are required but not used, example using Django:

class UserView(generic.View):
def get(self, request, user_id, *args, **kwargs):
try:
User.objects.get(id=user_id)
except User.DoesNotExist:
return http.HttpResponseNotFound()

In the above example `request`, `args` and `kwargs` are marked as unused, but they need to be defined because those are passed by the `dispatch` method.

In "Edit inspection profile settings" for "Unused local" there are the following options:
* Ignore variables used in tuple unpacking
* Ignore lambda parameters
* Ignore range iteration variables
* Ignore variables starting with '_'

It would be nice to be able to ignore "args and kwargs" as well as "all function parameters" (or even better be able to define which one to ignore).

I don't want to turn off "Unused local" inspection since it is very useful in many other places but I cannot suppress related code with "noinspection" as many project have "no IDE specific code" rule and suppression will work not only for parameters but the function content as well, which is not desirable.

Is there anything I can do about it?

2 comments

Hi,

I have filed an issue to our issue tracker https://youtrack.jetbrains.com/issue/PY-32472, please vote for it and follow for updates. 

0

Please sign in to leave a comment.