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.

abstract_method_py2.py 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. """Test abstract-method warning."""
  2. from __future__ import print_function
  3. # pylint: disable=missing-docstring, no-init, no-self-use
  4. # pylint: disable=too-few-public-methods
  5. import abc
  6. class Abstract(object):
  7. def aaaa(self):
  8. """should be overridden in concrete class"""
  9. raise NotImplementedError()
  10. def bbbb(self):
  11. """should be overridden in concrete class"""
  12. raise NotImplementedError()
  13. class AbstractB(Abstract):
  14. """Abstract class.
  15. this class is checking that it does not output an error msg for
  16. unimplemeted methods in abstract classes
  17. """
  18. def cccc(self):
  19. """should be overridden in concrete class"""
  20. raise NotImplementedError()
  21. class Concret(Abstract): # [abstract-method]
  22. """Concrete class"""
  23. def aaaa(self):
  24. """overidden form Abstract"""
  25. class Structure(object):
  26. __metaclass__ = abc.ABCMeta
  27. @abc.abstractmethod
  28. def __iter__(self):
  29. pass
  30. @abc.abstractmethod
  31. def __len__(self):
  32. pass
  33. @abc.abstractmethod
  34. def __contains__(self, _):
  35. pass
  36. @abc.abstractmethod
  37. def __hash__(self):
  38. pass
  39. # +1: [abstract-method, abstract-method, abstract-method]
  40. class Container(Structure):
  41. def __contains__(self, _):
  42. pass
  43. # +1: [abstract-method, abstract-method, abstract-method]
  44. class Sizable(Structure):
  45. def __len__(self):
  46. pass
  47. # +1: [abstract-method, abstract-method, abstract-method]
  48. class Hashable(Structure):
  49. __hash__ = 42
  50. # +1: [abstract-method, abstract-method, abstract-method]
  51. class Iterator(Structure):
  52. def keys(self):
  53. return iter([1, 2, 3])
  54. __iter__ = keys
  55. class AbstractSizable(Structure):
  56. @abc.abstractmethod
  57. def length(self):
  58. pass
  59. __len__ = length
  60. class GoodComplexMRO(Container, Iterator, Sizable, Hashable):
  61. pass
  62. # +1: [abstract-method, abstract-method, abstract-method]
  63. class BadComplexMro(Container, Iterator, AbstractSizable):
  64. pass