summaryrefslogtreecommitdiff
path: root/tests/functional/i/init_not_called.py
blob: 8f646eb262c19c0b26878f8d50d9670097ca774d (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
79
80
81
82
83
84
85
86
# pylint: disable=too-few-public-methods,import-error,missing-docstring,wrong-import-position,useless-super-delegation, useless-object-inheritance, unnecessary-pass
"""test for __init__ not called
"""
from __future__ import print_function

class AAAA:
    """ancestor 1"""

    def __init__(self):
        print('init', self)

class BBBB:
    """ancestor 2"""

    def __init__(self):
        print('init', self)

class CCCC:
    """ancestor 3"""


class ZZZZ(AAAA, BBBB, CCCC):
    """derived class"""

    def __init__(self):  # [super-init-not-called]
        AAAA.__init__(self)

class NewStyleA(object):
    """new style class"""
    def __init__(self):
        super().__init__()
        print('init', self)

class NewStyleB(NewStyleA):
    """derived new style class"""
    def __init__(self):
        super().__init__()

class NoInit(object):
    """No __init__ defined"""

class Init(NoInit):
    """Don't complain for not calling the super __init__"""

    def __init__(self, arg):
        self.arg = arg

class NewStyleC(object):
    """__init__ defined by assignment."""
    def xx_init(self):
        """Initializer."""
        pass

    __init__ = xx_init

class AssignedInit(NewStyleC):
    """No init called."""
    def __init__(self):  # [super-init-not-called]
        self.arg = 0

from missing import Missing

class UnknownBases(Missing):
    """Don't emit no-init if the bases aren't known."""


from typing import overload  # pylint: disable=wrong-import-order

class Parent:

    def __init__(self, num: int):
        self.number = num


class Child(Parent):

    @overload
    def __init__(self, num: int):
        ...

    @overload
    def __init__(self, num: float):
        ...

    def __init__(self, num):
        super().__init__(round(num))