summaryrefslogtreecommitdiff
path: root/tests/functional/u/unused/unused_argument.py
blob: f0b435f7063c9fc6f3560d628e7cb9e80d5e155b (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# pylint: disable=missing-docstring,too-few-public-methods, useless-object-inheritance

def test_unused(first, second, _not_used): # [unused-argument, unused-argument]
    pass


def test_prefixed_with_ignored(first, ignored_second):
    first()


def test_prefixed_with_unused(first, unused_second):
    first()

# for Sub.inherited, only the warning for "aay" is desired.
# The warnings for "aab" and "aac"  are most likely false positives though,
# because there could be another subclass that overrides the same method and does
# use the arguments (eg Sub2)


class Base(object):
    "parent"
    def inherited(self, aaa, aab, aac):
        "abstract method"
        raise NotImplementedError

class Sub(Base):
    "child 1"
    def inherited(self, aaa, aab, aac):
        "overridden method, though don't use every argument"
        return aaa

    def newmethod(self, aax, aay):  # [unused-argument]
        "another method, warning for aay desired"
        return self, aax

class Sub2(Base):
    "child 1"

    def inherited(self, aaa, aab, aac):
        "overridden method, use every argument"
        return aaa + aab + aac

def metadata_from_dict(key):
    """
    Should not raise unused-argument message because key is
    used inside comprehension dict
    """
    return {key: str(value) for key, value in key.items()}

# pylint: disable=R0903, print-statement, misplaced-future,wrong-import-position
from __future__ import print_function


def function(arg=1):  # [unused-argument]
    """ignore arg"""


class AAAA(object):
    """dummy class"""

    def method(self, arg):  # [unused-argument]
        """dummy method"""
        print(self)
    def __init__(self, *unused_args, **unused_kwargs):
        pass

    @classmethod
    def selected(cls, *args, **kwargs):  # [unused-argument, unused-argument]
        """called by the registry when the vobject has been selected.
        """
        return cls

    def using_inner_function(self, etype, size=1):
        """return a fake result set for a particular entity type"""
        rset = AAAA([('A',)]*size, '%s X' % etype,
                    description=[(etype,)]*size)
        def inner(row, col=0, etype=etype, req=self, rset=rset):
            """inner using all its argument"""
            # pylint: disable = E1103
            return req.vreg.etype_class(etype)(req, rset, row, col)
        # pylint: disable = W0201
        rset.get_entity = inner

class BBBB(object):
    """dummy class"""

    def __init__(self, arg):  # [unused-argument]
        """Constructor with an extra parameter. Should raise a warning"""
        self.spam = 1