File: func_unused_arguments.py

package info (click to toggle)
pylint-django 2.0.13-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 660 kB
  • sloc: python: 1,807; sh: 13; makefile: 5
file content (40 lines) | stat: -rw-r--r-- 1,261 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
Checks that Pylint still complains about unused-arguments for other
arguments if a function/method contains an argument named `request`.
"""
# pylint: disable=missing-docstring

from django.http import JsonResponse
from django.views import View

# Pylint generates the warning `redefined-outer-name` if an argument name shadows
# a variable name from an outer scope. But if that argument name is ignored this
# warning will not be generated.
# Therefore define request here to cover this behaviour in this test case.

request = None  # pylint: disable=invalid-name


def user_detail(request, user_id):  # [unused-argument]
    # nothing is done with user_id
    return JsonResponse({'username': 'steve'})


class UserView(View):
    def get(self, request, user_id):  # [unused-argument]
        # nothing is done with user_id
        return JsonResponse({'username': 'steve'})


# The following views are already covered in other test cases.
# They are included here for completeness sake.

def welcome_view(request):
    # just don't use `request' b/c we could have Django views
    # which never use it!
    return JsonResponse({'message': 'welcome'})


class CBV(View):
    def get(self, request):
        return JsonResponse({'message': 'hello world'})