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_py3.py 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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, metaclass=abc.ABCMeta):
  26. @abc.abstractmethod
  27. def __iter__(self):
  28. pass
  29. @abc.abstractmethod
  30. def __len__(self):
  31. pass
  32. @abc.abstractmethod
  33. def __contains__(self, _):
  34. pass
  35. @abc.abstractmethod
  36. def __hash__(self):
  37. pass
  38. # +1: [abstract-method, abstract-method, abstract-method]
  39. class Container(Structure):
  40. def __contains__(self, _):
  41. pass
  42. # +1: [abstract-method, abstract-method, abstract-method]
  43. class Sizable(Structure):
  44. def __len__(self):
  45. pass
  46. # +1: [abstract-method, abstract-method, abstract-method]
  47. class Hashable(Structure):
  48. __hash__ = 42
  49. # +1: [abstract-method, abstract-method, abstract-method]
  50. class Iterator(Structure):
  51. def keys(self):
  52. return iter([1, 2, 3])
  53. __iter__ = keys
  54. class AbstractSizable(Structure):
  55. @abc.abstractmethod
  56. def length(self):
  57. pass
  58. __len__ = length
  59. class GoodComplexMRO(Container, Iterator, Sizable, Hashable):
  60. pass
  61. # +1: [abstract-method, abstract-method, abstract-method]
  62. class BadComplexMro(Container, Iterator, AbstractSizable):
  63. pass