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.

arguments_differ.py 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. """Test that we are emitting arguments-differ when the arguments are different."""
  2. # pylint: disable=missing-docstring, too-few-public-methods, unused-argument,useless-super-delegation
  3. class Parent(object):
  4. def test(self):
  5. pass
  6. class Child(Parent):
  7. def test(self, arg): # [arguments-differ]
  8. pass
  9. class ParentDefaults(object):
  10. def test(self, arg=None, barg=None):
  11. pass
  12. class ChildDefaults(ParentDefaults):
  13. def test(self, arg=None): # [arguments-differ]
  14. pass
  15. class Classmethod(object):
  16. @classmethod
  17. def func(cls, data):
  18. return data
  19. @classmethod
  20. def func1(cls):
  21. return cls
  22. class ClassmethodChild(Classmethod):
  23. @staticmethod
  24. def func(): # [arguments-differ]
  25. pass
  26. @classmethod
  27. def func1(cls):
  28. return cls()
  29. class Builtins(dict):
  30. """Ignore for builtins, for which we don't know the number of required args."""
  31. @classmethod
  32. def fromkeys(cls, arg, arg1):
  33. pass
  34. class Varargs(object):
  35. def has_kwargs(self, arg, **kwargs):
  36. pass
  37. def no_kwargs(self, args):
  38. pass
  39. class VarargsChild(Varargs):
  40. def has_kwargs(self, arg): # [arguments-differ]
  41. "Not okay to lose capabilities."
  42. def no_kwargs(self, arg, **kwargs): # [arguments-differ]
  43. "Not okay to add extra capabilities."
  44. class Super(object):
  45. def __init__(self):
  46. pass
  47. def __private(self):
  48. pass
  49. def __private2_(self):
  50. pass
  51. def ___private3(self):
  52. pass
  53. def method(self, param):
  54. raise NotImplementedError
  55. class Sub(Super):
  56. # pylint: disable=unused-argument
  57. def __init__(self, arg):
  58. super(Sub, self).__init__()
  59. def __private(self, arg):
  60. pass
  61. def __private2_(self, arg):
  62. pass
  63. def ___private3(self, arg):
  64. pass
  65. def method(self, param='abc'):
  66. pass
  67. class Staticmethod(object):
  68. @staticmethod
  69. def func(data):
  70. return data
  71. class StaticmethodChild(Staticmethod):
  72. @classmethod
  73. def func(cls, data):
  74. return data
  75. class Property(object):
  76. @property
  77. def close(self):
  78. pass
  79. class PropertySetter(Property):
  80. @property
  81. def close(self):
  82. pass
  83. @close.setter
  84. def close(self, attr):
  85. return attr
  86. class StaticmethodChild2(Staticmethod):
  87. def func(self, data):
  88. super(StaticmethodChild2, self).func(data)
  89. class SuperClass(object):
  90. @staticmethod
  91. def impl(arg1, arg2, **kwargs):
  92. return arg1 + arg2
  93. class MyClass(SuperClass):
  94. def impl(self, *args, **kwargs): # [arguments-differ]
  95. super(MyClass, self).impl(*args, **kwargs)
  96. class FirstHasArgs(object):
  97. def test(self, *args):
  98. pass
  99. class SecondChangesArgs(FirstHasArgs):
  100. def test(self, first, second, *args): # [arguments-differ]
  101. pass
  102. class Positional(object):
  103. def test(self, first, second):
  104. pass
  105. class PositionalChild(Positional):
  106. def test(self, *args): # [arguments-differ]
  107. """Accepts too many.
  108. Why subclassing in the first case if the behavior is different?
  109. """
  110. super(PositionalChild, self).test(args[0], args[1])
  111. class HasSpecialMethod(object):
  112. def __getitem__(self, key):
  113. return key
  114. class OverridesSpecialMethod(HasSpecialMethod):
  115. def __getitem__(self, cheie):
  116. return cheie + 1
  117. class ParentClass(object):
  118. def meth(self, arg, arg1):
  119. raise NotImplementedError
  120. class ChildClass(ParentClass):
  121. def meth(self, _arg, dummy):
  122. pass