aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/a/assign/assignment_from_no_return.py
blob: 5415f60979e51210228622cb856eb6dde8f4709b (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
# pylint: disable=missing-docstring, invalid-name, too-few-public-methods, no-self-use


def some_func():
    pass


def decorate(func):
    """Decorate *fn* to return ``self`` to enable chained method calls."""
    def wrapper(self, *args, **kw):
        func(self, *args, **kw)
        return 42
    return wrapper


class Class:

    def some_method(self):
        pass

    @decorate
    def some_other_decorated_method(self):
        pass

    def some_other_method(self):
        value = self.some_method()  # [assignment-from-no-return]
        other_value = self.some_other_decorated_method()
        return value + other_value


VALUE = some_func() # [assignment-from-no-return]


class Parent:
    """Parent class"""

    def compute(self):
        """This isn't supported by all child classes"""

        # pylint: disable=no-self-use
        raise ValueError('Not supported for this object')

    def test(self):
        """Test"""

        result = self.compute()
        return result


class Child(Parent):
    """Child class"""

    def compute(self):
        """This is supported for this child class"""

        return 42


# Regression test for https://github.com/PyCQA/pylint/issues/4220
class A:
    """Parent class"""
    def f(self):
        """This returns something"""
        return 42


class B(A):
    """Child class"""
    def __init__(self):
        self.a = A()
        result = self.a.f()  # no error here
        print(result)

    def f(self):
        """This doesn't return anything"""


res = B().a.f()  # no error here