Development of an internal social media platform with personalised dashboards for students
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

func_noerror_e1101_9588_base_attr_aug_assign.py 991B

1234567891011121314151617181920212223242526272829303132333435363738
  1. # pylint: disable=R0903
  2. """
  3. False positive case of E1101:
  4. The error is triggered when the attribute set in the base class is
  5. modified with augmented assignment in a derived class.
  6. http://www.logilab.org/ticket/9588
  7. """
  8. __revision__ = 0
  9. class BaseClass(object):
  10. "The base class"
  11. def __init__(self):
  12. "Set an attribute."
  13. self.e1101 = 1
  14. class FalsePositiveClass(BaseClass):
  15. "The first derived class which triggers the false positive"
  16. def __init__(self):
  17. "Augmented assignment triggers E1101."
  18. BaseClass.__init__(self)
  19. self.e1101 += 1
  20. def countup(self):
  21. "Consequently this also triggers E1101."
  22. self.e1101 += 1
  23. class NegativeClass(BaseClass):
  24. "The second derived class, which does not trigger the error E1101"
  25. def __init__(self):
  26. "Ordinary assignment is OK."
  27. BaseClass.__init__(self)
  28. self.e1101 = self.e1101 + 1
  29. def countup(self):
  30. "No problem."
  31. self.e1101 += 1