aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/c/class_attributes.py
blob: 1d41f9d7a19c8f01014b6847998ee9f1ebd7e2e4 (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
"""Test that valid class attribute doesn't trigger errors"""
__revision__ = 'sponge bob'
# pylint: disable=useless-object-inheritance,missing-docstring,too-few-public-methods

class Clazz(object):
    "dummy class"

    def __init__(self):
        self.topic = 5
        self._data = 45

    def change_type(self, new_class):
        """Change type"""
        self.__class__ = new_class

    def do_nothing(self):
        "I do nothing useful"
        return self.topic + 56


class Base:
    _class_prop: int


class Child(Base):
    _class_prop = 42

    def method(self):
        print(self._class_prop)


Child().method()