Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f620214

Browse files
committedJun 24, 2022
[useless-parent-delegation] Rename functional test and merge old files
We don't need specific file for python 3.0 or 3.5 nowaydays
1 parent 8fd468c commit f620214

10 files changed

+132
-143
lines changed
 

‎tests/functional/u/useless/useless_super_delegation.py renamed to ‎tests/functional/u/useless/useless_parent_delegation.py

Lines changed: 106 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
# pylint: disable=line-too-long, useless-object-inheritance, arguments-out-of-order
44
# pylint: disable=super-with-arguments, dangerous-default-value
55

6+
import random
7+
from typing import Any, List
8+
69
default_var = 1
10+
11+
712
def not_a_method(param, param2):
813
return super(None, None).not_a_method(param, param2)
914

@@ -65,8 +70,8 @@ def with_default_arg_quad(self, first, default_arg="has_been_changed"):
6570
def with_default_unhandled(self, first, default_arg=lambda: True):
6671
super().with_default_arg_quad(first, default_arg)
6772

68-
class NotUselessSuper(Base):
6973

74+
class NotUselessSuper(Base):
7075
def multiple_statements(self):
7176
first = 42 * 24
7277
return super().multiple_statements() + first
@@ -117,14 +122,13 @@ def not_passing_default(self, first, second=None):
117122
return super(NotUselessSuper, self).not_passing_default(first)
118123

119124
def passing_only_a_handful(self, first, second, third, fourth):
120-
return super(NotUselessSuper, self).passing_only_a_handful(
121-
first, second)
125+
return super(NotUselessSuper, self).passing_only_a_handful(first, second)
122126

123127
def not_the_same_order(self, first, second, third):
124128
return super(NotUselessSuper, self).not_the_same_order(third, first, second)
125129

126130
def no_kwargs_in_signature(self, key=None):
127-
values = {'key': 'something'}
131+
values = {"key": "something"}
128132
return super(NotUselessSuper, self).no_kwargs_in_signature(**values)
129133

130134
def no_args_in_signature(self, first, second):
@@ -133,18 +137,16 @@ def no_args_in_signature(self, first, second):
133137

134138
def variadics_with_multiple_keyword_arguments(self, **kwargs):
135139
return super(NotUselessSuper, self).variadics_with_multiple_keyword_arguments(
136-
first=None,
137-
second=None,
138-
**kwargs)
140+
first=None, second=None, **kwargs
141+
)
139142

140143
def extraneous_keyword_params(self, none_ok=False):
141144
super(NotUselessSuper, self).extraneous_keyword_params(
142-
none_ok,
143-
valid_values=[23, 42])
145+
none_ok, valid_values=[23, 42]
146+
)
144147

145148
def extraneous_positional_args(self, **args):
146-
super(NotUselessSuper, self).extraneous_positional_args(
147-
1, 2, **args)
149+
super(NotUselessSuper, self).extraneous_positional_args(1, 2, **args)
148150

149151
def with_default_argument(self, first, default_arg="other"):
150152
# Not useless because the default_arg is different from the one in the base class
@@ -154,7 +156,7 @@ def without_default_argument(self, first, second=True):
154156
# Not useless because in the base class there is not default value for second argument
155157
super(NotUselessSuper, self).without_default_argument(first, second)
156158

157-
def with_default_argument_none(self, first, default_arg='NotNone'):
159+
def with_default_argument_none(self, first, default_arg="NotNone"):
158160
# Not useless because the default_arg is different from the one in the base class
159161
super(NotUselessSuper, self).with_default_argument_none(first, default_arg)
160162

@@ -170,19 +172,22 @@ def with_default_argument_tuple(self, first, default_arg=("42", "a")):
170172
# Not useless because the default_arg is different from the one in the base class
171173
super(NotUselessSuper, self).with_default_argument_tuple(first, default_arg)
172174

173-
def with_default_argument_dict(self, first, default_arg={'foo': 'bar'}):
175+
def with_default_argument_dict(self, first, default_arg={"foo": "bar"}):
174176
# Not useless because the default_arg is different from the one in the base class
175177
super(NotUselessSuper, self).with_default_argument_dict(first, default_arg)
176178

177179
default_var = 2
180+
178181
def with_default_argument_var(self, first, default_arg=default_var):
179182
# Not useless because the default_arg refers to a different variable from the one in the base class
180183
super(NotUselessSuper, self).with_default_argument_var(first, default_arg)
181184

182185
def with_default_argument_bis(self, first, default_arg="default"):
183186
# Although the default_arg is the same as in the base class, the call signature
184187
# differs. Thus it is not useless.
185-
super(NotUselessSuper, self).with_default_argument_bis(default_arg + "_argument")
188+
super(NotUselessSuper, self).with_default_argument_bis(
189+
default_arg + "_argument"
190+
)
186191

187192
def fake_method(self, param2="other"):
188193
super(NotUselessSuper, self).fake_method(param2)
@@ -202,31 +207,32 @@ def with_default_arg_ter(self, first, default_arg="has_been_changed_again"):
202207
def with_default_arg_quad(self, first, default_arg="has_been_changed"):
203208
# Not useless because the default value is the same as in the base but the
204209
# call is different from the signature
205-
super(NotUselessSuper, self).with_default_arg_quad(first, default_arg + "_and_modified")
210+
super(NotUselessSuper, self).with_default_arg_quad(
211+
first, default_arg + "_and_modified"
212+
)
206213

207214
def with_default_unhandled(self, first, default_arg=lambda: True):
208215
# Not useless because the default value type is not explicitly handled (Lambda), so assume they are different
209216
super(NotUselessSuper, self).with_default_unhandled(first, default_arg)
210217

211218

212219
class UselessSuper(Base):
213-
214-
def equivalent_params(self): # [useless-parent-delegation]
220+
def equivalent_params(self): # [useless-parent-delegation]
215221
return super(UselessSuper, self).equivalent_params()
216222

217-
def equivalent_params_1(self, first): # [useless-parent-delegation]
223+
def equivalent_params_1(self, first): # [useless-parent-delegation]
218224
return super(UselessSuper, self).equivalent_params_1(first)
219225

220-
def equivalent_params_2(self, *args): # [useless-parent-delegation]
226+
def equivalent_params_2(self, *args): # [useless-parent-delegation]
221227
return super(UselessSuper, self).equivalent_params_2(*args)
222228

223-
def equivalent_params_3(self, *args, **kwargs): # [useless-parent-delegation]
229+
def equivalent_params_3(self, *args, **kwargs): # [useless-parent-delegation]
224230
return super(UselessSuper, self).equivalent_params_3(*args, **kwargs)
225231

226-
def equivalent_params_4(self, first): # [useless-parent-delegation]
232+
def equivalent_params_4(self, first): # [useless-parent-delegation]
227233
super(UselessSuper, self).equivalent_params_4(first)
228234

229-
def equivalent_params_5(self, first, *args): # [useless-parent-delegation]
235+
def equivalent_params_5(self, first, *args): # [useless-parent-delegation]
230236
super(UselessSuper, self).equivalent_params_5(first, *args)
231237

232238
def equivalent_params_6(self, first, *args, **kwargs): # [useless-parent-delegation]
@@ -236,7 +242,7 @@ def with_default_argument(self, first, default_arg="default"): # [useless-parent
236242
# useless because the default value here is the same as in the base class
237243
return super(UselessSuper, self).with_default_argument(first, default_arg)
238244

239-
def without_default_argument(self, first, second): # [useless-parent-delegation]
245+
def without_default_argument(self, first, second): # [useless-parent-delegation]
240246
return super(UselessSuper, self).without_default_argument(first, second)
241247

242248
def with_default_argument_none(self, first, default_arg=None): # [useless-parent-delegation]
@@ -255,7 +261,7 @@ def with_default_argument_dict(self, first, default_arg={}): # [useless-parent-d
255261
def with_default_argument_var(self, first, default_arg=default_var): # [useless-parent-delegation]
256262
super(UselessSuper, self).with_default_argument_var(first, default_arg)
257263

258-
def __init__(self): # [useless-parent-delegation]
264+
def __init__(self): # [useless-parent-delegation]
259265
super(UselessSuper, self).__init__()
260266

261267
def with_default_arg(self, first, default_arg="only_in_super_base"): # [useless-parent-delegation]
@@ -276,7 +282,7 @@ def trigger_something(value_to_trigger):
276282

277283

278284
class NotUselessSuperDecorators(Base):
279-
@trigger_something('value1')
285+
@trigger_something("value1")
280286
def method_decorated(self):
281287
super(NotUselessSuperDecorators, self).method_decorated()
282288

@@ -299,9 +305,9 @@ def __hash__(self):
299305

300306
class DecoratedList(MyList):
301307
def __str__(self):
302-
return f'List -> {super().__str__()}'
308+
return f"List -> {super().__str__()}"
303309

304-
def __hash__(self): # [useless-parent-delegation]
310+
def __hash__(self): # [useless-parent-delegation]
305311
return super().__hash__()
306312

307313

@@ -334,3 +340,76 @@ def __init__(self, a, *args): # [useless-parent-delegation]
334340
class SubTwoTwo(SuperTwo):
335341
def __init__(self, a, b, *args):
336342
super().__init__(a, b, *args)
343+
344+
345+
class NotUselessSuperPy3(object):
346+
def not_passing_keyword_only(self, first, *, second):
347+
return super().not_passing_keyword_only(first)
348+
349+
def passing_keyword_only_with_modifications(self, first, *, second):
350+
return super().passing_keyword_only_with_modifications(first, second + 1)
351+
352+
353+
class AlsoNotUselessSuperPy3(NotUselessSuperPy3):
354+
def not_passing_keyword_only(self, first, *, second="second"):
355+
return super().not_passing_keyword_only(first, second=second)
356+
357+
358+
class UselessSuperPy3(object):
359+
def useless(self, *, first): # [useless-parent-delegation]
360+
super().useless(first=first)
361+
362+
363+
class Egg():
364+
def __init__(self, thing: object) -> None:
365+
pass
366+
367+
368+
class Spam(Egg):
369+
def __init__(self, thing: int) -> None:
370+
super().__init__(thing)
371+
372+
373+
class Ham(Egg):
374+
def __init__(self, thing: object) -> None: # [useless-parent-delegation]
375+
super().__init__(thing)
376+
377+
378+
class Test:
379+
def __init__(self, _arg: List[int]) -> None:
380+
super().__init__()
381+
382+
383+
class ReturnTypeAny:
384+
choices = ["a", 1, (2, 3)]
385+
386+
def draw(self) -> Any:
387+
return random.choice(self.choices)
388+
389+
390+
class ReturnTypeNarrowed(ReturnTypeAny):
391+
choices = [1, 2, 3]
392+
393+
def draw(self) -> int:
394+
return super().draw()
395+
396+
397+
class NoReturnType:
398+
choices = ["a", 1, (2, 3)]
399+
400+
def draw(self):
401+
return random.choice(self.choices)
402+
403+
404+
class ReturnTypeSpecified(NoReturnType):
405+
choices = ["a", "b"]
406+
407+
def draw(self) -> str: # [useless-parent-delegation]
408+
return super().draw()
409+
410+
411+
class ReturnTypeSame(ReturnTypeAny):
412+
choices = ["a", "b"]
413+
414+
def draw(self) -> Any: # [useless-parent-delegation]
415+
return super().draw()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
useless-parent-delegation:220:4:220:25:UselessSuper.equivalent_params:Useless parent or super() delegation in method 'equivalent_params':INFERENCE
2+
useless-parent-delegation:223:4:223:27:UselessSuper.equivalent_params_1:Useless parent or super() delegation in method 'equivalent_params_1':INFERENCE
3+
useless-parent-delegation:226:4:226:27:UselessSuper.equivalent_params_2:Useless parent or super() delegation in method 'equivalent_params_2':INFERENCE
4+
useless-parent-delegation:229:4:229:27:UselessSuper.equivalent_params_3:Useless parent or super() delegation in method 'equivalent_params_3':INFERENCE
5+
useless-parent-delegation:232:4:232:27:UselessSuper.equivalent_params_4:Useless parent or super() delegation in method 'equivalent_params_4':INFERENCE
6+
useless-parent-delegation:235:4:235:27:UselessSuper.equivalent_params_5:Useless parent or super() delegation in method 'equivalent_params_5':INFERENCE
7+
useless-parent-delegation:238:4:238:27:UselessSuper.equivalent_params_6:Useless parent or super() delegation in method 'equivalent_params_6':INFERENCE
8+
useless-parent-delegation:241:4:241:29:UselessSuper.with_default_argument:Useless parent or super() delegation in method 'with_default_argument':INFERENCE
9+
useless-parent-delegation:245:4:245:32:UselessSuper.without_default_argument:Useless parent or super() delegation in method 'without_default_argument':INFERENCE
10+
useless-parent-delegation:248:4:248:34:UselessSuper.with_default_argument_none:Useless parent or super() delegation in method 'with_default_argument_none':INFERENCE
11+
useless-parent-delegation:252:4:252:33:UselessSuper.with_default_argument_int:Useless parent or super() delegation in method 'with_default_argument_int':INFERENCE
12+
useless-parent-delegation:255:4:255:35:UselessSuper.with_default_argument_tuple:Useless parent or super() delegation in method 'with_default_argument_tuple':INFERENCE
13+
useless-parent-delegation:258:4:258:34:UselessSuper.with_default_argument_dict:Useless parent or super() delegation in method 'with_default_argument_dict':INFERENCE
14+
useless-parent-delegation:261:4:261:33:UselessSuper.with_default_argument_var:Useless parent or super() delegation in method 'with_default_argument_var':INFERENCE
15+
useless-parent-delegation:264:4:264:16:UselessSuper.__init__:Useless parent or super() delegation in method '__init__':INFERENCE
16+
useless-parent-delegation:267:4:267:24:UselessSuper.with_default_arg:Useless parent or super() delegation in method 'with_default_arg':INFERENCE
17+
useless-parent-delegation:270:4:270:28:UselessSuper.with_default_arg_bis:Useless parent or super() delegation in method 'with_default_arg_bis':INFERENCE
18+
useless-parent-delegation:273:4:273:28:UselessSuper.with_default_arg_ter:Useless parent or super() delegation in method 'with_default_arg_ter':INFERENCE
19+
useless-parent-delegation:276:4:276:29:UselessSuper.with_default_arg_quad:Useless parent or super() delegation in method 'with_default_arg_quad':INFERENCE
20+
useless-parent-delegation:310:4:310:16:DecoratedList.__hash__:Useless parent or super() delegation in method '__hash__':INFERENCE
21+
useless-parent-delegation:336:4:336:16:SubTwoOne.__init__:Useless parent or super() delegation in method '__init__':INFERENCE
22+
useless-parent-delegation:359:4:359:15:UselessSuperPy3.useless:Useless parent or super() delegation in method 'useless':INFERENCE
23+
useless-parent-delegation:374:4:374:16:Ham.__init__:Useless parent or super() delegation in method '__init__':INFERENCE
24+
useless-parent-delegation:407:4:407:12:ReturnTypeSpecified.draw:Useless parent or super() delegation in method 'draw':INFERENCE
25+
useless-parent-delegation:414:4:414:12:ReturnTypeSame.draw:Useless parent or super() delegation in method 'draw':INFERENCE
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
useless-parent-delegation:16:4:16:16:Ham.__init__:Useless parent delegation in method '__init__':INFERENCE
1+
useless-parent-delegation:16:4:16:16:Ham.__init__:Useless parent or super() delegation in method '__init__':INFERENCE

‎tests/functional/u/useless/useless_super_delegation.txt

Lines changed: 0 additions & 21 deletions
This file was deleted.

‎tests/functional/u/useless/useless_super_delegation_py3.py

Lines changed: 0 additions & 43 deletions
This file was deleted.

‎tests/functional/u/useless/useless_super_delegation_py3.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

‎tests/functional/u/useless/useless_super_delegation_py35.py

Lines changed: 0 additions & 46 deletions
This file was deleted.
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Please sign in to comment.