-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
super_init_not_called.py
50 lines (31 loc) · 1.28 KB
/
super_init_not_called.py
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
"""Tests for super-init-not-called."""
# pylint: disable=too-few-public-methods, missing-class-docstring
import ctypes
class Foo(ctypes.BigEndianStructure):
"""This class should not emit a super-init-not-called warning.
It previously did, because ``next(node.infer())`` was used in that checker's logic
and the first inferred node was an Uninferable object, leading to this false positive.
"""
def __init__(self):
ctypes.BigEndianStructure.__init__(self)
class UninferableChild(UninferableParent): # [undefined-variable]
"""An implementation that test if we don't crash on uninferable parents."""
def __init__(self):
...
# Tests for not calling the init of a parent that does not define one
# but inherits it.
class GrandParentWithInit:
def __init__(self):
print(self)
class ParentWithoutInit(GrandParentWithInit):
pass
class ChildOne(ParentWithoutInit, GrandParentWithInit):
"""Since ParentWithoutInit calls GrandParentWithInit it doesn't need to be called."""
def __init__(self):
GrandParentWithInit.__init__(self)
class ChildTwo(ParentWithoutInit):
def __init__(self):
ParentWithoutInit.__init__(self)
class ChildThree(ParentWithoutInit):
def __init__(self): # [super-init-not-called]
...