summaryrefslogtreecommitdiff
path: root/pylint/test/input/func_method_could_be_function.py
blob: 92a85bcfdf339a8e2f0227cc97da773892f78d6a (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
# pylint: disable=R0903,W0232,print-statement
"""test detection of method which could be a function"""

__revision__ = None

class Toto(object):
    """bla bal abl"""

    def __init__(self):
        self.aaa = 2

    def regular_method(self):
        """this method is a real method since it access to self"""
        self.function_method()

    def function_method(self):
        """this method isn' a real method since it doesn't need self"""
        print 'hello'


class Base(object):
    """an abstract class"""

    def __init__(self):
        self.aaa = 2

    def check(self, arg):
        """an abstract method, could not be a function"""
        raise NotImplementedError


class Sub(Base):
    """a concret class"""

    def check(self, arg):
        """a concret method, could not be a function since it need
        polymorphism benefits
        """
        return arg == 0

class Super(object):
    """same as before without abstract"""
    attr = 1
    def method(self):
        """regular"""
        print self.attr

class Sub1(Super):
    """override method with need for self"""
    def method(self):
        """no i can not be a function"""
        print 42

    def __len__(self):
        """no i can not be a function"""
        print 42

    def __cmp__(self, other):
        """no i can not be a function"""
        print 42