Try to search your question here, if you can't find : Ask Any Question Now ?

Should I always trust W0613 pylint warnings in Django, especially for functions which have **kwargs as parameters?

HomeCategory: stackoverflowShould I always trust W0613 pylint warnings in Django, especially for functions which have **kwargs as parameters?
Avatarjohn asked 4 months ago

Using Pylint on Django code, I frequently get the W0613 warning. 90% of the time the cases are relevant, when the variable is declared and not used. But sometimes I think it’s not.

W0613: Unused argument 'kwargs' (unused-argument)

Example that triggers the warning, a view that handles the 500 error:

def error_500(request, *args, **kwargs):
    '''
    A 500 error handling view
    '''
    data = {}
    return render(request, '500.html', data)

In the above case if we remove **kwargs, starting by Django 2.2 (as I remember), any 500 error situation leads to an unhandled exception which turns into a crash.

So I am confused if Pylint really understands all the situations that can appear or not.

Should I always treat the warning as a real warning because my code lacks something, or should I know these exceptional case?

I noticed that by using the special Pylint for Django this type of warning usually doesn’t appear as often (pylint-django).

But this is a case where the W0613 gets triggered even with the Pylint-django plugin loaded in Pylint:

@csrf_exempt
def ipn(sender, **kwargs):
    '''
    Paypal IPN listener. It gets triggered after every each payment.
    '''
    msg = sender.POST.get('payer_email')
    print(msg)
    sys.stdin = sender
    return HttpResponse(msg)
1 Answers
Best Answer
AvatarMikhail answered 4 months ago
Your Answer

12 + 13 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com