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.

init_not_called.py 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. # pylint: disable=R0903,import-error,missing-docstring,wrong-import-position,useless-super-delegation
  2. """test for __init__ not called
  3. """
  4. from __future__ import print_function
  5. class AAAA: # <3.0:[old-style-class]
  6. """ancestor 1"""
  7. def __init__(self):
  8. print('init', self)
  9. class BBBB: # <3.0:[old-style-class]
  10. """ancestor 2"""
  11. def __init__(self):
  12. print('init', self)
  13. class CCCC: # <3.0:[old-style-class,no-init]
  14. """ancestor 3"""
  15. class ZZZZ(AAAA, BBBB, CCCC):
  16. """derived class"""
  17. def __init__(self): # [super-init-not-called]
  18. AAAA.__init__(self)
  19. class NewStyleA(object):
  20. """new style class"""
  21. def __init__(self):
  22. super(NewStyleA, self).__init__()
  23. print('init', self)
  24. class NewStyleB(NewStyleA):
  25. """derived new style class"""
  26. def __init__(self):
  27. super(NewStyleB, self).__init__()
  28. class NoInit(object):
  29. """No __init__ defined"""
  30. class Init(NoInit):
  31. """Don't complain for not calling the super __init__"""
  32. def __init__(self, arg):
  33. self.arg = arg
  34. class NewStyleC(object):
  35. """__init__ defined by assignment."""
  36. def xx_init(self):
  37. """Initializer."""
  38. pass
  39. __init__ = xx_init
  40. class AssignedInit(NewStyleC):
  41. """No init called."""
  42. def __init__(self): # [super-init-not-called]
  43. self.arg = 0
  44. from missing import Missing
  45. class UnknownBases(Missing):
  46. """Don't emit no-init if the bases aren't known."""