summaryrefslogtreecommitdiff
path: root/tests/functional/r/regression/regression_properties_in_class_context.py
blob: 067dcaa2782122fb797a12b0b4cd19f95ed1c438 (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
# pylint: disable=missing-docstring,too-few-public-methods

class Meta(type):
    @property
    def values(cls):
        return ['foo', 'bar']


class Parent(metaclass=Meta):
    pass


assert 'foo' in Parent.values  # no warning
for value in Parent.values:  # no warning
    print(value)


class Child(Parent):
    pass


assert 'foo' in Child.values  # false-positive: unsupported-membership-test
for value in Child.values:  # false-positive: not-an-iterable
    print(value)


class Meta2(type):
    def a_method(cls):
        return [123]


class Parent2(metaclass=Meta2):
    @property
    def a_method(self):
        return "actually a property"


class Child2(Parent2):
    pass


assert 123 in Child2.a_method  # [unsupported-membership-test]
for value in Child2.a_method:  # [not-an-iterable]
    print(value)