blob: 9fe95fd4ba99e6ff4b3a72206b81731392ebd1b1 (
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
|
# pylint: disable=too-few-public-methods
"""
False positive case of E1101:
The error is triggered when the attribute set in the base class is
modified with augmented assignment in a derived class.
https://www.logilab.org/ticket/9588
"""
class BaseClass:
"The base class"
def __init__(self):
"Set an attribute."
self.e1101 = 1
class FalsePositiveClass(BaseClass):
"The first derived class which triggers the false positive"
def __init__(self):
"Augmented assignment triggers E1101."
BaseClass.__init__(self)
self.e1101 += 1
def countup(self):
"Consequently this also triggers E1101."
self.e1101 += 1
class NegativeClass(BaseClass):
"The second derived class, which does not trigger the error E1101"
def __init__(self):
"Ordinary assignment is OK."
BaseClass.__init__(self)
self.e1101 = self.e1101 + 1
def countup(self):
"No problem."
self.e1101 += 1
|