summaryrefslogtreecommitdiff
path: root/pylint/test/input/func_init_vars.py
blob: 473d1ccbc8deb7728166e9335d18c1079306c78a (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
"""Checks that class variables are seen as inherited !
"""
# pylint: disable=too-few-public-methods
from __future__ import print_function


class MyClass(object):
    """Inherits from nothing
    """

    def __init__(self):
        self.var = {}

    def met(self):
        """Checks that base_var is seen as defined outside '__init__'
        """
        self.var[1] = 'one'
        self.base_var = 'one'
        print(self.base_var, self.var)

    def met2(self):
        """dummy method"""
        print(self)
class MySubClass(MyClass):
    """Inherits from MyClass
    """
    class_attr = 1

    def __init__(self):
        MyClass.__init__(self)
        self.var2 = 2
        print(self.__doc__)
        print(self.__dict__)
        print(self.__class__)

    def met2(self):
        """Checks that var is seen as defined outside '__init__'
        """
        self.var[1] = 'one'
        self.var2 += 1
        print(self.class_attr)

if __name__ == '__main__':
    OBJ = MyClass()
    OBJ.met()