[Python-projects] false positive E1101 for augmented assignment

MATSUI Fe2+ Tetsushi VED03370 at nifty.ne.jp
Fri Jul 3 14:00:51 CEST 2009


Hi

I encountered a false positive E1101 for augmented assignment.
See the following sample code.

"""
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.
"""

class BaseClass(object):
    "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


I'm using
pylint 0.18.0, 
astng 0.19.0, common 0.41.0
Python 2.5.4

Thank you in advance
-- 
MATSUI "Fe2+" Tetsushi



More information about the Python-Projects mailing list