From de343649c74ac2507ac8161fed8916dcf6944eec Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 15 Jun 2022 09:49:03 +0200 Subject: [PATCH 1/3] [useless-super-delegation] Rename the message to useless-parent-delegation --- .../bad.py | 2 +- .../good.py | 0 .../related.rst | 0 doc/whatsnew/2/2.15/index.rst | 4 ++ pylint/checkers/classes/class_checker.py | 13 +++--- .../u/useless/useless_super_delegation.py | 42 +++++++++---------- .../u/useless/useless_super_delegation.txt | 42 +++++++++---------- .../u/useless/useless_super_delegation_py3.py | 4 +- .../useless/useless_super_delegation_py3.txt | 4 +- .../useless/useless_super_delegation_py35.py | 6 +-- .../useless/useless_super_delegation_py35.txt | 6 +-- .../useless/useless_super_delegation_py38.py | 2 +- .../useless/useless_super_delegation_py38.txt | 2 +- 13 files changed, 65 insertions(+), 62 deletions(-) rename doc/data/messages/u/{useless-super-delegation => useless-parent-delegation}/bad.py (70%) rename doc/data/messages/u/{useless-super-delegation => useless-parent-delegation}/good.py (100%) rename doc/data/messages/u/{useless-super-delegation => useless-parent-delegation}/related.rst (100%) diff --git a/doc/data/messages/u/useless-super-delegation/bad.py b/doc/data/messages/u/useless-parent-delegation/bad.py similarity index 70% rename from doc/data/messages/u/useless-super-delegation/bad.py rename to doc/data/messages/u/useless-parent-delegation/bad.py index 0c13bd40f6..9010c9ea9b 100644 --- a/doc/data/messages/u/useless-super-delegation/bad.py +++ b/doc/data/messages/u/useless-parent-delegation/bad.py @@ -6,5 +6,5 @@ def eat(self, food): class Human(Animal): - def eat(self, food): # [useless-super-delegation] + def eat(self, food): # [useless-parent-delegation] super(Human, self).eat(food) diff --git a/doc/data/messages/u/useless-super-delegation/good.py b/doc/data/messages/u/useless-parent-delegation/good.py similarity index 100% rename from doc/data/messages/u/useless-super-delegation/good.py rename to doc/data/messages/u/useless-parent-delegation/good.py diff --git a/doc/data/messages/u/useless-super-delegation/related.rst b/doc/data/messages/u/useless-parent-delegation/related.rst similarity index 100% rename from doc/data/messages/u/useless-super-delegation/related.rst rename to doc/data/messages/u/useless-parent-delegation/related.rst diff --git a/doc/whatsnew/2/2.15/index.rst b/doc/whatsnew/2/2.15/index.rst index bffe76603a..e8ce187909 100644 --- a/doc/whatsnew/2/2.15/index.rst +++ b/doc/whatsnew/2/2.15/index.rst @@ -77,6 +77,10 @@ Other bug fixes Other Changes ============= +* ``useless-super-delegation`` has been renamed to ``useless-parent-delegation`` in order to be more generic. + + Closes #6953 + Internal changes ================ diff --git a/pylint/checkers/classes/class_checker.py b/pylint/checkers/classes/class_checker.py index 933e65c6c7..775a22460c 100644 --- a/pylint/checkers/classes/class_checker.py +++ b/pylint/checkers/classes/class_checker.py @@ -470,9 +470,7 @@ def _has_same_layout_slots(slots, assigned_value): return False -MSGS: dict[ - str, MessageDefinitionTuple -] = { # pylint: disable=consider-using-namedtuple-or-dataclass +MSGS: dict[str, MessageDefinitionTuple] = { "F0202": ( "Unable to check methods signature (%s / %s)", "method-check-failed", @@ -579,12 +577,13 @@ def _has_same_layout_slots(slots, assigned_value): "Used when an __init__ method is called on a class which is not " "in the direct ancestors for the analysed class.", ), - "W0235": ( - "Useless super delegation in method %r", - "useless-super-delegation", + "W0246": ( + "Useless parent or super() delegation in method %r", + "useless-parent-delegation", "Used whenever we can detect that an overridden method is useless, " - "relying on super() delegation to do the same thing as another method " + "relying on parent or super() delegation to do the same thing as another method " "from the MRO.", + {"old_names": [("W0235", "useless-super-delegation")]}, ), "W0236": ( "Method %r was expected to be %r, found it instead as %r", diff --git a/tests/functional/u/useless/useless_super_delegation.py b/tests/functional/u/useless/useless_super_delegation.py index cc7d51b65e..0bd1bdb058 100644 --- a/tests/functional/u/useless/useless_super_delegation.py +++ b/tests/functional/u/useless/useless_super_delegation.py @@ -211,63 +211,63 @@ def with_default_unhandled(self, first, default_arg=lambda: True): class UselessSuper(Base): - def equivalent_params(self): # [useless-super-delegation] + def equivalent_params(self): # [useless-parent-delegation] return super(UselessSuper, self).equivalent_params() - def equivalent_params_1(self, first): # [useless-super-delegation] + def equivalent_params_1(self, first): # [useless-parent-delegation] return super(UselessSuper, self).equivalent_params_1(first) - def equivalent_params_2(self, *args): # [useless-super-delegation] + def equivalent_params_2(self, *args): # [useless-parent-delegation] return super(UselessSuper, self).equivalent_params_2(*args) - def equivalent_params_3(self, *args, **kwargs): # [useless-super-delegation] + def equivalent_params_3(self, *args, **kwargs): # [useless-parent-delegation] return super(UselessSuper, self).equivalent_params_3(*args, **kwargs) - def equivalent_params_4(self, first): # [useless-super-delegation] + def equivalent_params_4(self, first): # [useless-parent-delegation] super(UselessSuper, self).equivalent_params_4(first) - def equivalent_params_5(self, first, *args): # [useless-super-delegation] + def equivalent_params_5(self, first, *args): # [useless-parent-delegation] super(UselessSuper, self).equivalent_params_5(first, *args) - def equivalent_params_6(self, first, *args, **kwargs): # [useless-super-delegation] + def equivalent_params_6(self, first, *args, **kwargs): # [useless-parent-delegation] return super(UselessSuper, self).equivalent_params_6(first, *args, **kwargs) - def with_default_argument(self, first, default_arg="default"): # [useless-super-delegation] + def with_default_argument(self, first, default_arg="default"): # [useless-parent-delegation] # useless because the default value here is the same as in the base class return super(UselessSuper, self).with_default_argument(first, default_arg) - def without_default_argument(self, first, second): # [useless-super-delegation] + def without_default_argument(self, first, second): # [useless-parent-delegation] return super(UselessSuper, self).without_default_argument(first, second) - def with_default_argument_none(self, first, default_arg=None): # [useless-super-delegation] + def with_default_argument_none(self, first, default_arg=None): # [useless-parent-delegation] # useless because the default value here is the same as in the base class super(UselessSuper, self).with_default_argument_none(first, default_arg) - def with_default_argument_int(self, first, default_arg=42): # [useless-super-delegation] + def with_default_argument_int(self, first, default_arg=42): # [useless-parent-delegation] super(UselessSuper, self).with_default_argument_int(first, default_arg) - def with_default_argument_tuple(self, first, default_arg=()): # [useless-super-delegation] + def with_default_argument_tuple(self, first, default_arg=()): # [useless-parent-delegation] super(UselessSuper, self).with_default_argument_tuple(first, default_arg) - def with_default_argument_dict(self, first, default_arg={}): # [useless-super-delegation] + def with_default_argument_dict(self, first, default_arg={}): # [useless-parent-delegation] super(UselessSuper, self).with_default_argument_dict(first, default_arg) - def with_default_argument_var(self, first, default_arg=default_var): # [useless-super-delegation] + def with_default_argument_var(self, first, default_arg=default_var): # [useless-parent-delegation] super(UselessSuper, self).with_default_argument_var(first, default_arg) - def __init__(self): # [useless-super-delegation] + def __init__(self): # [useless-parent-delegation] super(UselessSuper, self).__init__() - def with_default_arg(self, first, default_arg="only_in_super_base"): # [useless-super-delegation] + def with_default_arg(self, first, default_arg="only_in_super_base"): # [useless-parent-delegation] super(UselessSuper, self).with_default_arg(first, default_arg) - def with_default_arg_bis(self, first, default_arg="only_in_super_base"): # [useless-super-delegation] + def with_default_arg_bis(self, first, default_arg="only_in_super_base"): # [useless-parent-delegation] super(UselessSuper, self).with_default_arg_bis(first, default_arg) - def with_default_arg_ter(self, first, default_arg="has_been_changed"): # [useless-super-delegation] + def with_default_arg_ter(self, first, default_arg="has_been_changed"): # [useless-parent-delegation] super(UselessSuper, self).with_default_arg_ter(first, default_arg) - def with_default_arg_quad(self, first, default_arg="has_been_changed"): # [useless-super-delegation] + def with_default_arg_quad(self, first, default_arg="has_been_changed"): # [useless-parent-delegation] super(UselessSuper, self).with_default_arg_quad(first, default_arg) @@ -301,7 +301,7 @@ class DecoratedList(MyList): def __str__(self): return f'List -> {super().__str__()}' - def __hash__(self): # [useless-super-delegation] + def __hash__(self): # [useless-parent-delegation] return super().__hash__() @@ -327,7 +327,7 @@ def __init__(self, a, *args): class SubTwoOne(SuperTwo): - def __init__(self, a, *args): # [useless-super-delegation] + def __init__(self, a, *args): # [useless-parent-delegation] super().__init__(a, *args) diff --git a/tests/functional/u/useless/useless_super_delegation.txt b/tests/functional/u/useless/useless_super_delegation.txt index 9cf3115732..d3e4ef7929 100644 --- a/tests/functional/u/useless/useless_super_delegation.txt +++ b/tests/functional/u/useless/useless_super_delegation.txt @@ -1,21 +1,21 @@ -useless-super-delegation:214:4:214:25:UselessSuper.equivalent_params:Useless super delegation in method 'equivalent_params':UNDEFINED -useless-super-delegation:217:4:217:27:UselessSuper.equivalent_params_1:Useless super delegation in method 'equivalent_params_1':UNDEFINED -useless-super-delegation:220:4:220:27:UselessSuper.equivalent_params_2:Useless super delegation in method 'equivalent_params_2':UNDEFINED -useless-super-delegation:223:4:223:27:UselessSuper.equivalent_params_3:Useless super delegation in method 'equivalent_params_3':UNDEFINED -useless-super-delegation:226:4:226:27:UselessSuper.equivalent_params_4:Useless super delegation in method 'equivalent_params_4':UNDEFINED -useless-super-delegation:229:4:229:27:UselessSuper.equivalent_params_5:Useless super delegation in method 'equivalent_params_5':UNDEFINED -useless-super-delegation:232:4:232:27:UselessSuper.equivalent_params_6:Useless super delegation in method 'equivalent_params_6':UNDEFINED -useless-super-delegation:235:4:235:29:UselessSuper.with_default_argument:Useless super delegation in method 'with_default_argument':UNDEFINED -useless-super-delegation:239:4:239:32:UselessSuper.without_default_argument:Useless super delegation in method 'without_default_argument':UNDEFINED -useless-super-delegation:242:4:242:34:UselessSuper.with_default_argument_none:Useless super delegation in method 'with_default_argument_none':UNDEFINED -useless-super-delegation:246:4:246:33:UselessSuper.with_default_argument_int:Useless super delegation in method 'with_default_argument_int':UNDEFINED -useless-super-delegation:249:4:249:35:UselessSuper.with_default_argument_tuple:Useless super delegation in method 'with_default_argument_tuple':UNDEFINED -useless-super-delegation:252:4:252:34:UselessSuper.with_default_argument_dict:Useless super delegation in method 'with_default_argument_dict':UNDEFINED -useless-super-delegation:255:4:255:33:UselessSuper.with_default_argument_var:Useless super delegation in method 'with_default_argument_var':UNDEFINED -useless-super-delegation:258:4:258:16:UselessSuper.__init__:Useless super delegation in method '__init__':UNDEFINED -useless-super-delegation:261:4:261:24:UselessSuper.with_default_arg:Useless super delegation in method 'with_default_arg':UNDEFINED -useless-super-delegation:264:4:264:28:UselessSuper.with_default_arg_bis:Useless super delegation in method 'with_default_arg_bis':UNDEFINED -useless-super-delegation:267:4:267:28:UselessSuper.with_default_arg_ter:Useless super delegation in method 'with_default_arg_ter':UNDEFINED -useless-super-delegation:270:4:270:29:UselessSuper.with_default_arg_quad:Useless super delegation in method 'with_default_arg_quad':UNDEFINED -useless-super-delegation:304:4:304:16:DecoratedList.__hash__:Useless super delegation in method '__hash__':UNDEFINED -useless-super-delegation:330:4:330:16:SubTwoOne.__init__:Useless super delegation in method '__init__':UNDEFINED +useless-parent-delegation:214:4:214:25:UselessSuper.equivalent_params:Useless parent delegation in method 'equivalent_params':UNDEFINED +useless-parent-delegation:217:4:217:27:UselessSuper.equivalent_params_1:Useless parent delegation in method 'equivalent_params_1':UNDEFINED +useless-parent-delegation:220:4:220:27:UselessSuper.equivalent_params_2:Useless parent delegation in method 'equivalent_params_2':UNDEFINED +useless-parent-delegation:223:4:223:27:UselessSuper.equivalent_params_3:Useless parent delegation in method 'equivalent_params_3':UNDEFINED +useless-parent-delegation:226:4:226:27:UselessSuper.equivalent_params_4:Useless parent delegation in method 'equivalent_params_4':UNDEFINED +useless-parent-delegation:229:4:229:27:UselessSuper.equivalent_params_5:Useless parent delegation in method 'equivalent_params_5':UNDEFINED +useless-parent-delegation:232:4:232:27:UselessSuper.equivalent_params_6:Useless parent delegation in method 'equivalent_params_6':UNDEFINED +useless-parent-delegation:235:4:235:29:UselessSuper.with_default_argument:Useless parent delegation in method 'with_default_argument':UNDEFINED +useless-parent-delegation:239:4:239:32:UselessSuper.without_default_argument:Useless parent delegation in method 'without_default_argument':UNDEFINED +useless-parent-delegation:242:4:242:34:UselessSuper.with_default_argument_none:Useless parent delegation in method 'with_default_argument_none':UNDEFINED +useless-parent-delegation:246:4:246:33:UselessSuper.with_default_argument_int:Useless parent delegation in method 'with_default_argument_int':UNDEFINED +useless-parent-delegation:249:4:249:35:UselessSuper.with_default_argument_tuple:Useless parent delegation in method 'with_default_argument_tuple':UNDEFINED +useless-parent-delegation:252:4:252:34:UselessSuper.with_default_argument_dict:Useless parent delegation in method 'with_default_argument_dict':UNDEFINED +useless-parent-delegation:255:4:255:33:UselessSuper.with_default_argument_var:Useless parent delegation in method 'with_default_argument_var':UNDEFINED +useless-parent-delegation:258:4:258:16:UselessSuper.__init__:Useless parent delegation in method '__init__':UNDEFINED +useless-parent-delegation:261:4:261:24:UselessSuper.with_default_arg:Useless parent delegation in method 'with_default_arg':UNDEFINED +useless-parent-delegation:264:4:264:28:UselessSuper.with_default_arg_bis:Useless parent delegation in method 'with_default_arg_bis':UNDEFINED +useless-parent-delegation:267:4:267:28:UselessSuper.with_default_arg_ter:Useless parent delegation in method 'with_default_arg_ter':UNDEFINED +useless-parent-delegation:270:4:270:29:UselessSuper.with_default_arg_quad:Useless parent delegation in method 'with_default_arg_quad':UNDEFINED +useless-parent-delegation:304:4:304:16:DecoratedList.__hash__:Useless parent delegation in method '__hash__':UNDEFINED +useless-parent-delegation:330:4:330:16:SubTwoOne.__init__:Useless parent delegation in method '__init__':UNDEFINED diff --git a/tests/functional/u/useless/useless_super_delegation_py3.py b/tests/functional/u/useless/useless_super_delegation_py3.py index b32ced873b..9208d16926 100644 --- a/tests/functional/u/useless/useless_super_delegation_py3.py +++ b/tests/functional/u/useless/useless_super_delegation_py3.py @@ -18,7 +18,7 @@ def not_passing_keyword_only(self, first, *, second="second"): class UselessSuper(object): - def useless(self, *, first): # [useless-super-delegation] + def useless(self, *, first): # [useless-parent-delegation] super().useless(first=first) @@ -31,7 +31,7 @@ def __init__(self, thing: int) -> None: super().__init__(thing) class Ham(Egg): - def __init__(self, thing: object) -> None: # [useless-super-delegation] + def __init__(self, thing: object) -> None: # [useless-parent-delegation] super().__init__(thing) diff --git a/tests/functional/u/useless/useless_super_delegation_py3.txt b/tests/functional/u/useless/useless_super_delegation_py3.txt index 2497504a06..2520cccb09 100644 --- a/tests/functional/u/useless/useless_super_delegation_py3.txt +++ b/tests/functional/u/useless/useless_super_delegation_py3.txt @@ -1,2 +1,2 @@ -useless-super-delegation:21:4:21:15:UselessSuper.useless:Useless super delegation in method 'useless':UNDEFINED -useless-super-delegation:34:4:34:16:Ham.__init__:Useless super delegation in method '__init__':UNDEFINED +useless-parent-delegation:21:4:21:15:UselessSuper.useless:Useless parent delegation in method 'useless':UNDEFINED +useless-parent-delegation:34:4:34:16:Ham.__init__:Useless parent delegation in method '__init__':UNDEFINED diff --git a/tests/functional/u/useless/useless_super_delegation_py35.py b/tests/functional/u/useless/useless_super_delegation_py35.py index 789ae55d3d..a405ffb99b 100644 --- a/tests/functional/u/useless/useless_super_delegation_py35.py +++ b/tests/functional/u/useless/useless_super_delegation_py35.py @@ -8,7 +8,7 @@ def not_passing_all_params(self, first, *args, second=None, **kwargs): class UselessSuper(object): - def useless(self, first, *, second=None, **kwargs): # [useless-super-delegation] + def useless(self, first, *, second=None, **kwargs): # [useless-parent-delegation] return super().useless(first, second=second, **kwargs) # pylint: disable=wrong-import-position @@ -36,11 +36,11 @@ def draw(self): class ReturnTypeSpecified(NoReturnType): choices = ['a', 'b'] - def draw(self) -> str: # [useless-super-delegation] + def draw(self) -> str: # [useless-parent-delegation] return super().draw() class ReturnTypeSame(ReturnTypeAny): choices = ['a', 'b'] - def draw(self) -> Any: # [useless-super-delegation] + def draw(self) -> Any: # [useless-parent-delegation] return super().draw() diff --git a/tests/functional/u/useless/useless_super_delegation_py35.txt b/tests/functional/u/useless/useless_super_delegation_py35.txt index 58c98b0f99..f2a62e7aa0 100644 --- a/tests/functional/u/useless/useless_super_delegation_py35.txt +++ b/tests/functional/u/useless/useless_super_delegation_py35.txt @@ -1,3 +1,3 @@ -useless-super-delegation:11:4:11:15:UselessSuper.useless:Useless super delegation in method 'useless':UNDEFINED -useless-super-delegation:39:4:39:12:ReturnTypeSpecified.draw:Useless super delegation in method 'draw':UNDEFINED -useless-super-delegation:45:4:45:12:ReturnTypeSame.draw:Useless super delegation in method 'draw':UNDEFINED +useless-parent-delegation:11:4:11:15:UselessSuper.useless:Useless parent delegation in method 'useless':UNDEFINED +useless-parent-delegation:39:4:39:12:ReturnTypeSpecified.draw:Useless parent delegation in method 'draw':UNDEFINED +useless-parent-delegation:45:4:45:12:ReturnTypeSame.draw:Useless parent delegation in method 'draw':UNDEFINED diff --git a/tests/functional/u/useless/useless_super_delegation_py38.py b/tests/functional/u/useless/useless_super_delegation_py38.py index ec402299f7..dded3b2cb8 100644 --- a/tests/functional/u/useless/useless_super_delegation_py38.py +++ b/tests/functional/u/useless/useless_super_delegation_py38.py @@ -13,5 +13,5 @@ def __init__(self, first: float, /, second: float) -> None: class Ham(Egg): - def __init__(self, first: Any, /, second: Any) -> None: # [useless-super-delegation] + def __init__(self, first: Any, /, second: Any) -> None: # [useless-parent-delegation] super().__init__(first, second) diff --git a/tests/functional/u/useless/useless_super_delegation_py38.txt b/tests/functional/u/useless/useless_super_delegation_py38.txt index 1c4631c938..a5b2295c97 100644 --- a/tests/functional/u/useless/useless_super_delegation_py38.txt +++ b/tests/functional/u/useless/useless_super_delegation_py38.txt @@ -1 +1 @@ -useless-super-delegation:16:4:16:16:Ham.__init__:Useless super delegation in method '__init__':UNDEFINED +useless-parent-delegation:16:4:16:16:Ham.__init__:Useless parent delegation in method '__init__':UNDEFINED From 8fd468c889aaf71554bc688e4df70676b40db4df Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Wed, 15 Jun 2022 09:59:44 +0200 Subject: [PATCH 2/3] [usless-parent-delegation] Set confidence to inference instead of undefined --- pylint/checkers/classes/class_checker.py | 7 +++- .../u/useless/useless_super_delegation.txt | 42 +++++++++---------- .../useless/useless_super_delegation_py3.txt | 4 +- .../useless/useless_super_delegation_py35.txt | 6 +-- .../useless/useless_super_delegation_py38.txt | 2 +- 5 files changed, 32 insertions(+), 29 deletions(-) diff --git a/pylint/checkers/classes/class_checker.py b/pylint/checkers/classes/class_checker.py index 775a22460c..ba5edad64b 100644 --- a/pylint/checkers/classes/class_checker.py +++ b/pylint/checkers/classes/class_checker.py @@ -73,7 +73,7 @@ def _signature_from_call(call): for keyword in call.keywords or []: arg, value = keyword.arg, keyword.value if arg is None and isinstance(value, nodes.Name): - # Starred node and we are interested only in names, + # Starred node, and we are interested only in names, # otherwise some transformation might occur for the parameter. starred_kws.append(value.name) elif isinstance(value, nodes.Name): @@ -1304,7 +1304,10 @@ def form_annotations(arguments): if _definition_equivalent_to_call(params, args): self.add_message( - "useless-super-delegation", node=function, args=(function.name,) + "useless-parent-delegation", + node=function, + args=(function.name,), + confidence=INFERENCE, ) def _check_property_with_parameters(self, node): diff --git a/tests/functional/u/useless/useless_super_delegation.txt b/tests/functional/u/useless/useless_super_delegation.txt index d3e4ef7929..ea0af810ac 100644 --- a/tests/functional/u/useless/useless_super_delegation.txt +++ b/tests/functional/u/useless/useless_super_delegation.txt @@ -1,21 +1,21 @@ -useless-parent-delegation:214:4:214:25:UselessSuper.equivalent_params:Useless parent delegation in method 'equivalent_params':UNDEFINED -useless-parent-delegation:217:4:217:27:UselessSuper.equivalent_params_1:Useless parent delegation in method 'equivalent_params_1':UNDEFINED -useless-parent-delegation:220:4:220:27:UselessSuper.equivalent_params_2:Useless parent delegation in method 'equivalent_params_2':UNDEFINED -useless-parent-delegation:223:4:223:27:UselessSuper.equivalent_params_3:Useless parent delegation in method 'equivalent_params_3':UNDEFINED -useless-parent-delegation:226:4:226:27:UselessSuper.equivalent_params_4:Useless parent delegation in method 'equivalent_params_4':UNDEFINED -useless-parent-delegation:229:4:229:27:UselessSuper.equivalent_params_5:Useless parent delegation in method 'equivalent_params_5':UNDEFINED -useless-parent-delegation:232:4:232:27:UselessSuper.equivalent_params_6:Useless parent delegation in method 'equivalent_params_6':UNDEFINED -useless-parent-delegation:235:4:235:29:UselessSuper.with_default_argument:Useless parent delegation in method 'with_default_argument':UNDEFINED -useless-parent-delegation:239:4:239:32:UselessSuper.without_default_argument:Useless parent delegation in method 'without_default_argument':UNDEFINED -useless-parent-delegation:242:4:242:34:UselessSuper.with_default_argument_none:Useless parent delegation in method 'with_default_argument_none':UNDEFINED -useless-parent-delegation:246:4:246:33:UselessSuper.with_default_argument_int:Useless parent delegation in method 'with_default_argument_int':UNDEFINED -useless-parent-delegation:249:4:249:35:UselessSuper.with_default_argument_tuple:Useless parent delegation in method 'with_default_argument_tuple':UNDEFINED -useless-parent-delegation:252:4:252:34:UselessSuper.with_default_argument_dict:Useless parent delegation in method 'with_default_argument_dict':UNDEFINED -useless-parent-delegation:255:4:255:33:UselessSuper.with_default_argument_var:Useless parent delegation in method 'with_default_argument_var':UNDEFINED -useless-parent-delegation:258:4:258:16:UselessSuper.__init__:Useless parent delegation in method '__init__':UNDEFINED -useless-parent-delegation:261:4:261:24:UselessSuper.with_default_arg:Useless parent delegation in method 'with_default_arg':UNDEFINED -useless-parent-delegation:264:4:264:28:UselessSuper.with_default_arg_bis:Useless parent delegation in method 'with_default_arg_bis':UNDEFINED -useless-parent-delegation:267:4:267:28:UselessSuper.with_default_arg_ter:Useless parent delegation in method 'with_default_arg_ter':UNDEFINED -useless-parent-delegation:270:4:270:29:UselessSuper.with_default_arg_quad:Useless parent delegation in method 'with_default_arg_quad':UNDEFINED -useless-parent-delegation:304:4:304:16:DecoratedList.__hash__:Useless parent delegation in method '__hash__':UNDEFINED -useless-parent-delegation:330:4:330:16:SubTwoOne.__init__:Useless parent delegation in method '__init__':UNDEFINED +useless-parent-delegation:214:4:214:25:UselessSuper.equivalent_params:Useless parent delegation in method 'equivalent_params':INFERENCE +useless-parent-delegation:217:4:217:27:UselessSuper.equivalent_params_1:Useless parent delegation in method 'equivalent_params_1':INFERENCE +useless-parent-delegation:220:4:220:27:UselessSuper.equivalent_params_2:Useless parent delegation in method 'equivalent_params_2':INFERENCE +useless-parent-delegation:223:4:223:27:UselessSuper.equivalent_params_3:Useless parent delegation in method 'equivalent_params_3':INFERENCE +useless-parent-delegation:226:4:226:27:UselessSuper.equivalent_params_4:Useless parent delegation in method 'equivalent_params_4':INFERENCE +useless-parent-delegation:229:4:229:27:UselessSuper.equivalent_params_5:Useless parent delegation in method 'equivalent_params_5':INFERENCE +useless-parent-delegation:232:4:232:27:UselessSuper.equivalent_params_6:Useless parent delegation in method 'equivalent_params_6':INFERENCE +useless-parent-delegation:235:4:235:29:UselessSuper.with_default_argument:Useless parent delegation in method 'with_default_argument':INFERENCE +useless-parent-delegation:239:4:239:32:UselessSuper.without_default_argument:Useless parent delegation in method 'without_default_argument':INFERENCE +useless-parent-delegation:242:4:242:34:UselessSuper.with_default_argument_none:Useless parent delegation in method 'with_default_argument_none':INFERENCE +useless-parent-delegation:246:4:246:33:UselessSuper.with_default_argument_int:Useless parent delegation in method 'with_default_argument_int':INFERENCE +useless-parent-delegation:249:4:249:35:UselessSuper.with_default_argument_tuple:Useless parent delegation in method 'with_default_argument_tuple':INFERENCE +useless-parent-delegation:252:4:252:34:UselessSuper.with_default_argument_dict:Useless parent delegation in method 'with_default_argument_dict':INFERENCE +useless-parent-delegation:255:4:255:33:UselessSuper.with_default_argument_var:Useless parent delegation in method 'with_default_argument_var':INFERENCE +useless-parent-delegation:258:4:258:16:UselessSuper.__init__:Useless parent delegation in method '__init__':INFERENCE +useless-parent-delegation:261:4:261:24:UselessSuper.with_default_arg:Useless parent delegation in method 'with_default_arg':INFERENCE +useless-parent-delegation:264:4:264:28:UselessSuper.with_default_arg_bis:Useless parent delegation in method 'with_default_arg_bis':INFERENCE +useless-parent-delegation:267:4:267:28:UselessSuper.with_default_arg_ter:Useless parent delegation in method 'with_default_arg_ter':INFERENCE +useless-parent-delegation:270:4:270:29:UselessSuper.with_default_arg_quad:Useless parent delegation in method 'with_default_arg_quad':INFERENCE +useless-parent-delegation:304:4:304:16:DecoratedList.__hash__:Useless parent delegation in method '__hash__':INFERENCE +useless-parent-delegation:330:4:330:16:SubTwoOne.__init__:Useless parent delegation in method '__init__':INFERENCE diff --git a/tests/functional/u/useless/useless_super_delegation_py3.txt b/tests/functional/u/useless/useless_super_delegation_py3.txt index 2520cccb09..c957e422dc 100644 --- a/tests/functional/u/useless/useless_super_delegation_py3.txt +++ b/tests/functional/u/useless/useless_super_delegation_py3.txt @@ -1,2 +1,2 @@ -useless-parent-delegation:21:4:21:15:UselessSuper.useless:Useless parent delegation in method 'useless':UNDEFINED -useless-parent-delegation:34:4:34:16:Ham.__init__:Useless parent delegation in method '__init__':UNDEFINED +useless-parent-delegation:21:4:21:15:UselessSuper.useless:Useless parent delegation in method 'useless':INFERENCE +useless-parent-delegation:34:4:34:16:Ham.__init__:Useless parent delegation in method '__init__':INFERENCE diff --git a/tests/functional/u/useless/useless_super_delegation_py35.txt b/tests/functional/u/useless/useless_super_delegation_py35.txt index f2a62e7aa0..7077b1ccc2 100644 --- a/tests/functional/u/useless/useless_super_delegation_py35.txt +++ b/tests/functional/u/useless/useless_super_delegation_py35.txt @@ -1,3 +1,3 @@ -useless-parent-delegation:11:4:11:15:UselessSuper.useless:Useless parent delegation in method 'useless':UNDEFINED -useless-parent-delegation:39:4:39:12:ReturnTypeSpecified.draw:Useless parent delegation in method 'draw':UNDEFINED -useless-parent-delegation:45:4:45:12:ReturnTypeSame.draw:Useless parent delegation in method 'draw':UNDEFINED +useless-parent-delegation:11:4:11:15:UselessSuper.useless:Useless parent delegation in method 'useless':INFERENCE +useless-parent-delegation:39:4:39:12:ReturnTypeSpecified.draw:Useless parent delegation in method 'draw':INFERENCE +useless-parent-delegation:45:4:45:12:ReturnTypeSame.draw:Useless parent delegation in method 'draw':INFERENCE diff --git a/tests/functional/u/useless/useless_super_delegation_py38.txt b/tests/functional/u/useless/useless_super_delegation_py38.txt index a5b2295c97..1243063747 100644 --- a/tests/functional/u/useless/useless_super_delegation_py38.txt +++ b/tests/functional/u/useless/useless_super_delegation_py38.txt @@ -1 +1 @@ -useless-parent-delegation:16:4:16:16:Ham.__init__:Useless parent delegation in method '__init__':UNDEFINED +useless-parent-delegation:16:4:16:16:Ham.__init__:Useless parent delegation in method '__init__':INFERENCE From f62021444a7df8a84f8c0bb305b1435a3a49b6ae Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Fri, 24 Jun 2022 09:29:02 +0200 Subject: [PATCH 3/3] [useless-parent-delegation] Rename functional test and merge old files We don't need specific file for python 3.0 or 3.5 nowaydays --- ...gation.py => useless_parent_delegation.py} | 133 ++++++++++++++---- .../u/useless/useless_parent_delegation.txt | 25 ++++ ...8.py => useless_parent_delegation_py38.py} | 0 ...8.rc => useless_parent_delegation_py38.rc} | 0 ...txt => useless_parent_delegation_py38.txt} | 2 +- .../u/useless/useless_super_delegation.txt | 21 --- .../u/useless/useless_super_delegation_py3.py | 43 ------ .../useless/useless_super_delegation_py3.txt | 2 - .../useless/useless_super_delegation_py35.py | 46 ------ .../useless/useless_super_delegation_py35.txt | 3 - 10 files changed, 132 insertions(+), 143 deletions(-) rename tests/functional/u/useless/{useless_super_delegation.py => useless_parent_delegation.py} (79%) create mode 100644 tests/functional/u/useless/useless_parent_delegation.txt rename tests/functional/u/useless/{useless_super_delegation_py38.py => useless_parent_delegation_py38.py} (100%) rename tests/functional/u/useless/{useless_super_delegation_py38.rc => useless_parent_delegation_py38.rc} (100%) rename tests/functional/u/useless/{useless_super_delegation_py38.txt => useless_parent_delegation_py38.txt} (54%) delete mode 100644 tests/functional/u/useless/useless_super_delegation.txt delete mode 100644 tests/functional/u/useless/useless_super_delegation_py3.py delete mode 100644 tests/functional/u/useless/useless_super_delegation_py3.txt delete mode 100644 tests/functional/u/useless/useless_super_delegation_py35.py delete mode 100644 tests/functional/u/useless/useless_super_delegation_py35.txt diff --git a/tests/functional/u/useless/useless_super_delegation.py b/tests/functional/u/useless/useless_parent_delegation.py similarity index 79% rename from tests/functional/u/useless/useless_super_delegation.py rename to tests/functional/u/useless/useless_parent_delegation.py index 0bd1bdb058..5f8179c276 100644 --- a/tests/functional/u/useless/useless_super_delegation.py +++ b/tests/functional/u/useless/useless_parent_delegation.py @@ -3,7 +3,12 @@ # pylint: disable=line-too-long, useless-object-inheritance, arguments-out-of-order # pylint: disable=super-with-arguments, dangerous-default-value +import random +from typing import Any, List + default_var = 1 + + def not_a_method(param, param2): return super(None, None).not_a_method(param, param2) @@ -65,8 +70,8 @@ def with_default_arg_quad(self, first, default_arg="has_been_changed"): def with_default_unhandled(self, first, default_arg=lambda: True): super().with_default_arg_quad(first, default_arg) -class NotUselessSuper(Base): +class NotUselessSuper(Base): def multiple_statements(self): first = 42 * 24 return super().multiple_statements() + first @@ -117,14 +122,13 @@ def not_passing_default(self, first, second=None): return super(NotUselessSuper, self).not_passing_default(first) def passing_only_a_handful(self, first, second, third, fourth): - return super(NotUselessSuper, self).passing_only_a_handful( - first, second) + return super(NotUselessSuper, self).passing_only_a_handful(first, second) def not_the_same_order(self, first, second, third): return super(NotUselessSuper, self).not_the_same_order(third, first, second) def no_kwargs_in_signature(self, key=None): - values = {'key': 'something'} + values = {"key": "something"} return super(NotUselessSuper, self).no_kwargs_in_signature(**values) def no_args_in_signature(self, first, second): @@ -133,18 +137,16 @@ def no_args_in_signature(self, first, second): def variadics_with_multiple_keyword_arguments(self, **kwargs): return super(NotUselessSuper, self).variadics_with_multiple_keyword_arguments( - first=None, - second=None, - **kwargs) + first=None, second=None, **kwargs + ) def extraneous_keyword_params(self, none_ok=False): super(NotUselessSuper, self).extraneous_keyword_params( - none_ok, - valid_values=[23, 42]) + none_ok, valid_values=[23, 42] + ) def extraneous_positional_args(self, **args): - super(NotUselessSuper, self).extraneous_positional_args( - 1, 2, **args) + super(NotUselessSuper, self).extraneous_positional_args(1, 2, **args) def with_default_argument(self, first, default_arg="other"): # 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): # Not useless because in the base class there is not default value for second argument super(NotUselessSuper, self).without_default_argument(first, second) - def with_default_argument_none(self, first, default_arg='NotNone'): + def with_default_argument_none(self, first, default_arg="NotNone"): # Not useless because the default_arg is different from the one in the base class super(NotUselessSuper, self).with_default_argument_none(first, default_arg) @@ -170,11 +172,12 @@ def with_default_argument_tuple(self, first, default_arg=("42", "a")): # Not useless because the default_arg is different from the one in the base class super(NotUselessSuper, self).with_default_argument_tuple(first, default_arg) - def with_default_argument_dict(self, first, default_arg={'foo': 'bar'}): + def with_default_argument_dict(self, first, default_arg={"foo": "bar"}): # Not useless because the default_arg is different from the one in the base class super(NotUselessSuper, self).with_default_argument_dict(first, default_arg) default_var = 2 + def with_default_argument_var(self, first, default_arg=default_var): # Not useless because the default_arg refers to a different variable from the one in the base class super(NotUselessSuper, self).with_default_argument_var(first, default_arg) @@ -182,7 +185,9 @@ def with_default_argument_var(self, first, default_arg=default_var): def with_default_argument_bis(self, first, default_arg="default"): # Although the default_arg is the same as in the base class, the call signature # differs. Thus it is not useless. - super(NotUselessSuper, self).with_default_argument_bis(default_arg + "_argument") + super(NotUselessSuper, self).with_default_argument_bis( + default_arg + "_argument" + ) def fake_method(self, param2="other"): super(NotUselessSuper, self).fake_method(param2) @@ -202,7 +207,9 @@ def with_default_arg_ter(self, first, default_arg="has_been_changed_again"): def with_default_arg_quad(self, first, default_arg="has_been_changed"): # Not useless because the default value is the same as in the base but the # call is different from the signature - super(NotUselessSuper, self).with_default_arg_quad(first, default_arg + "_and_modified") + super(NotUselessSuper, self).with_default_arg_quad( + first, default_arg + "_and_modified" + ) def with_default_unhandled(self, first, default_arg=lambda: True): # Not useless because the default value type is not explicitly handled (Lambda), so assume they are different @@ -210,23 +217,22 @@ def with_default_unhandled(self, first, default_arg=lambda: True): class UselessSuper(Base): - - def equivalent_params(self): # [useless-parent-delegation] + def equivalent_params(self): # [useless-parent-delegation] return super(UselessSuper, self).equivalent_params() - def equivalent_params_1(self, first): # [useless-parent-delegation] + def equivalent_params_1(self, first): # [useless-parent-delegation] return super(UselessSuper, self).equivalent_params_1(first) - def equivalent_params_2(self, *args): # [useless-parent-delegation] + def equivalent_params_2(self, *args): # [useless-parent-delegation] return super(UselessSuper, self).equivalent_params_2(*args) - def equivalent_params_3(self, *args, **kwargs): # [useless-parent-delegation] + def equivalent_params_3(self, *args, **kwargs): # [useless-parent-delegation] return super(UselessSuper, self).equivalent_params_3(*args, **kwargs) - def equivalent_params_4(self, first): # [useless-parent-delegation] + def equivalent_params_4(self, first): # [useless-parent-delegation] super(UselessSuper, self).equivalent_params_4(first) - def equivalent_params_5(self, first, *args): # [useless-parent-delegation] + def equivalent_params_5(self, first, *args): # [useless-parent-delegation] super(UselessSuper, self).equivalent_params_5(first, *args) 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 # useless because the default value here is the same as in the base class return super(UselessSuper, self).with_default_argument(first, default_arg) - def without_default_argument(self, first, second): # [useless-parent-delegation] + def without_default_argument(self, first, second): # [useless-parent-delegation] return super(UselessSuper, self).without_default_argument(first, second) 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 def with_default_argument_var(self, first, default_arg=default_var): # [useless-parent-delegation] super(UselessSuper, self).with_default_argument_var(first, default_arg) - def __init__(self): # [useless-parent-delegation] + def __init__(self): # [useless-parent-delegation] super(UselessSuper, self).__init__() 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): class NotUselessSuperDecorators(Base): - @trigger_something('value1') + @trigger_something("value1") def method_decorated(self): super(NotUselessSuperDecorators, self).method_decorated() @@ -299,9 +305,9 @@ def __hash__(self): class DecoratedList(MyList): def __str__(self): - return f'List -> {super().__str__()}' + return f"List -> {super().__str__()}" - def __hash__(self): # [useless-parent-delegation] + def __hash__(self): # [useless-parent-delegation] return super().__hash__() @@ -334,3 +340,76 @@ def __init__(self, a, *args): # [useless-parent-delegation] class SubTwoTwo(SuperTwo): def __init__(self, a, b, *args): super().__init__(a, b, *args) + + +class NotUselessSuperPy3(object): + def not_passing_keyword_only(self, first, *, second): + return super().not_passing_keyword_only(first) + + def passing_keyword_only_with_modifications(self, first, *, second): + return super().passing_keyword_only_with_modifications(first, second + 1) + + +class AlsoNotUselessSuperPy3(NotUselessSuperPy3): + def not_passing_keyword_only(self, first, *, second="second"): + return super().not_passing_keyword_only(first, second=second) + + +class UselessSuperPy3(object): + def useless(self, *, first): # [useless-parent-delegation] + super().useless(first=first) + + +class Egg(): + def __init__(self, thing: object) -> None: + pass + + +class Spam(Egg): + def __init__(self, thing: int) -> None: + super().__init__(thing) + + +class Ham(Egg): + def __init__(self, thing: object) -> None: # [useless-parent-delegation] + super().__init__(thing) + + +class Test: + def __init__(self, _arg: List[int]) -> None: + super().__init__() + + +class ReturnTypeAny: + choices = ["a", 1, (2, 3)] + + def draw(self) -> Any: + return random.choice(self.choices) + + +class ReturnTypeNarrowed(ReturnTypeAny): + choices = [1, 2, 3] + + def draw(self) -> int: + return super().draw() + + +class NoReturnType: + choices = ["a", 1, (2, 3)] + + def draw(self): + return random.choice(self.choices) + + +class ReturnTypeSpecified(NoReturnType): + choices = ["a", "b"] + + def draw(self) -> str: # [useless-parent-delegation] + return super().draw() + + +class ReturnTypeSame(ReturnTypeAny): + choices = ["a", "b"] + + def draw(self) -> Any: # [useless-parent-delegation] + return super().draw() diff --git a/tests/functional/u/useless/useless_parent_delegation.txt b/tests/functional/u/useless/useless_parent_delegation.txt new file mode 100644 index 0000000000..2d79897f8c --- /dev/null +++ b/tests/functional/u/useless/useless_parent_delegation.txt @@ -0,0 +1,25 @@ +useless-parent-delegation:220:4:220:25:UselessSuper.equivalent_params:Useless parent or super() delegation in method 'equivalent_params':INFERENCE +useless-parent-delegation:223:4:223:27:UselessSuper.equivalent_params_1:Useless parent or super() delegation in method 'equivalent_params_1':INFERENCE +useless-parent-delegation:226:4:226:27:UselessSuper.equivalent_params_2:Useless parent or super() delegation in method 'equivalent_params_2':INFERENCE +useless-parent-delegation:229:4:229:27:UselessSuper.equivalent_params_3:Useless parent or super() delegation in method 'equivalent_params_3':INFERENCE +useless-parent-delegation:232:4:232:27:UselessSuper.equivalent_params_4:Useless parent or super() delegation in method 'equivalent_params_4':INFERENCE +useless-parent-delegation:235:4:235:27:UselessSuper.equivalent_params_5:Useless parent or super() delegation in method 'equivalent_params_5':INFERENCE +useless-parent-delegation:238:4:238:27:UselessSuper.equivalent_params_6:Useless parent or super() delegation in method 'equivalent_params_6':INFERENCE +useless-parent-delegation:241:4:241:29:UselessSuper.with_default_argument:Useless parent or super() delegation in method 'with_default_argument':INFERENCE +useless-parent-delegation:245:4:245:32:UselessSuper.without_default_argument:Useless parent or super() delegation in method 'without_default_argument':INFERENCE +useless-parent-delegation:248:4:248:34:UselessSuper.with_default_argument_none:Useless parent or super() delegation in method 'with_default_argument_none':INFERENCE +useless-parent-delegation:252:4:252:33:UselessSuper.with_default_argument_int:Useless parent or super() delegation in method 'with_default_argument_int':INFERENCE +useless-parent-delegation:255:4:255:35:UselessSuper.with_default_argument_tuple:Useless parent or super() delegation in method 'with_default_argument_tuple':INFERENCE +useless-parent-delegation:258:4:258:34:UselessSuper.with_default_argument_dict:Useless parent or super() delegation in method 'with_default_argument_dict':INFERENCE +useless-parent-delegation:261:4:261:33:UselessSuper.with_default_argument_var:Useless parent or super() delegation in method 'with_default_argument_var':INFERENCE +useless-parent-delegation:264:4:264:16:UselessSuper.__init__:Useless parent or super() delegation in method '__init__':INFERENCE +useless-parent-delegation:267:4:267:24:UselessSuper.with_default_arg:Useless parent or super() delegation in method 'with_default_arg':INFERENCE +useless-parent-delegation:270:4:270:28:UselessSuper.with_default_arg_bis:Useless parent or super() delegation in method 'with_default_arg_bis':INFERENCE +useless-parent-delegation:273:4:273:28:UselessSuper.with_default_arg_ter:Useless parent or super() delegation in method 'with_default_arg_ter':INFERENCE +useless-parent-delegation:276:4:276:29:UselessSuper.with_default_arg_quad:Useless parent or super() delegation in method 'with_default_arg_quad':INFERENCE +useless-parent-delegation:310:4:310:16:DecoratedList.__hash__:Useless parent or super() delegation in method '__hash__':INFERENCE +useless-parent-delegation:336:4:336:16:SubTwoOne.__init__:Useless parent or super() delegation in method '__init__':INFERENCE +useless-parent-delegation:359:4:359:15:UselessSuperPy3.useless:Useless parent or super() delegation in method 'useless':INFERENCE +useless-parent-delegation:374:4:374:16:Ham.__init__:Useless parent or super() delegation in method '__init__':INFERENCE +useless-parent-delegation:407:4:407:12:ReturnTypeSpecified.draw:Useless parent or super() delegation in method 'draw':INFERENCE +useless-parent-delegation:414:4:414:12:ReturnTypeSame.draw:Useless parent or super() delegation in method 'draw':INFERENCE diff --git a/tests/functional/u/useless/useless_super_delegation_py38.py b/tests/functional/u/useless/useless_parent_delegation_py38.py similarity index 100% rename from tests/functional/u/useless/useless_super_delegation_py38.py rename to tests/functional/u/useless/useless_parent_delegation_py38.py diff --git a/tests/functional/u/useless/useless_super_delegation_py38.rc b/tests/functional/u/useless/useless_parent_delegation_py38.rc similarity index 100% rename from tests/functional/u/useless/useless_super_delegation_py38.rc rename to tests/functional/u/useless/useless_parent_delegation_py38.rc diff --git a/tests/functional/u/useless/useless_super_delegation_py38.txt b/tests/functional/u/useless/useless_parent_delegation_py38.txt similarity index 54% rename from tests/functional/u/useless/useless_super_delegation_py38.txt rename to tests/functional/u/useless/useless_parent_delegation_py38.txt index 1243063747..a42a822149 100644 --- a/tests/functional/u/useless/useless_super_delegation_py38.txt +++ b/tests/functional/u/useless/useless_parent_delegation_py38.txt @@ -1 +1 @@ -useless-parent-delegation:16:4:16:16:Ham.__init__:Useless parent delegation in method '__init__':INFERENCE +useless-parent-delegation:16:4:16:16:Ham.__init__:Useless parent or super() delegation in method '__init__':INFERENCE diff --git a/tests/functional/u/useless/useless_super_delegation.txt b/tests/functional/u/useless/useless_super_delegation.txt deleted file mode 100644 index ea0af810ac..0000000000 --- a/tests/functional/u/useless/useless_super_delegation.txt +++ /dev/null @@ -1,21 +0,0 @@ -useless-parent-delegation:214:4:214:25:UselessSuper.equivalent_params:Useless parent delegation in method 'equivalent_params':INFERENCE -useless-parent-delegation:217:4:217:27:UselessSuper.equivalent_params_1:Useless parent delegation in method 'equivalent_params_1':INFERENCE -useless-parent-delegation:220:4:220:27:UselessSuper.equivalent_params_2:Useless parent delegation in method 'equivalent_params_2':INFERENCE -useless-parent-delegation:223:4:223:27:UselessSuper.equivalent_params_3:Useless parent delegation in method 'equivalent_params_3':INFERENCE -useless-parent-delegation:226:4:226:27:UselessSuper.equivalent_params_4:Useless parent delegation in method 'equivalent_params_4':INFERENCE -useless-parent-delegation:229:4:229:27:UselessSuper.equivalent_params_5:Useless parent delegation in method 'equivalent_params_5':INFERENCE -useless-parent-delegation:232:4:232:27:UselessSuper.equivalent_params_6:Useless parent delegation in method 'equivalent_params_6':INFERENCE -useless-parent-delegation:235:4:235:29:UselessSuper.with_default_argument:Useless parent delegation in method 'with_default_argument':INFERENCE -useless-parent-delegation:239:4:239:32:UselessSuper.without_default_argument:Useless parent delegation in method 'without_default_argument':INFERENCE -useless-parent-delegation:242:4:242:34:UselessSuper.with_default_argument_none:Useless parent delegation in method 'with_default_argument_none':INFERENCE -useless-parent-delegation:246:4:246:33:UselessSuper.with_default_argument_int:Useless parent delegation in method 'with_default_argument_int':INFERENCE -useless-parent-delegation:249:4:249:35:UselessSuper.with_default_argument_tuple:Useless parent delegation in method 'with_default_argument_tuple':INFERENCE -useless-parent-delegation:252:4:252:34:UselessSuper.with_default_argument_dict:Useless parent delegation in method 'with_default_argument_dict':INFERENCE -useless-parent-delegation:255:4:255:33:UselessSuper.with_default_argument_var:Useless parent delegation in method 'with_default_argument_var':INFERENCE -useless-parent-delegation:258:4:258:16:UselessSuper.__init__:Useless parent delegation in method '__init__':INFERENCE -useless-parent-delegation:261:4:261:24:UselessSuper.with_default_arg:Useless parent delegation in method 'with_default_arg':INFERENCE -useless-parent-delegation:264:4:264:28:UselessSuper.with_default_arg_bis:Useless parent delegation in method 'with_default_arg_bis':INFERENCE -useless-parent-delegation:267:4:267:28:UselessSuper.with_default_arg_ter:Useless parent delegation in method 'with_default_arg_ter':INFERENCE -useless-parent-delegation:270:4:270:29:UselessSuper.with_default_arg_quad:Useless parent delegation in method 'with_default_arg_quad':INFERENCE -useless-parent-delegation:304:4:304:16:DecoratedList.__hash__:Useless parent delegation in method '__hash__':INFERENCE -useless-parent-delegation:330:4:330:16:SubTwoOne.__init__:Useless parent delegation in method '__init__':INFERENCE diff --git a/tests/functional/u/useless/useless_super_delegation_py3.py b/tests/functional/u/useless/useless_super_delegation_py3.py deleted file mode 100644 index 9208d16926..0000000000 --- a/tests/functional/u/useless/useless_super_delegation_py3.py +++ /dev/null @@ -1,43 +0,0 @@ -# pylint: disable=missing-docstring, no-member, unused-argument, invalid-name,unused-variable -# pylint: disable=too-few-public-methods,wrong-import-position, useless-object-inheritance - -class NotUselessSuper(object): - - def not_passing_keyword_only(self, first, *, second): - return super().not_passing_keyword_only(first) - - def passing_keyword_only_with_modifications(self, first, *, second): - return super().passing_keyword_only_with_modifications( - first, second + 1) - - -class AlsoNotUselessSuper(NotUselessSuper): - def not_passing_keyword_only(self, first, *, second="second"): - return super().not_passing_keyword_only(first, second=second) - - -class UselessSuper(object): - - def useless(self, *, first): # [useless-parent-delegation] - super().useless(first=first) - - -class Egg(): - def __init__(self, thing: object) -> None: - pass - -class Spam(Egg): - def __init__(self, thing: int) -> None: - super().__init__(thing) - -class Ham(Egg): - def __init__(self, thing: object) -> None: # [useless-parent-delegation] - super().__init__(thing) - - -from typing import List - - -class Test: - def __init__(self, _arg: List[int]) -> None: - super().__init__() diff --git a/tests/functional/u/useless/useless_super_delegation_py3.txt b/tests/functional/u/useless/useless_super_delegation_py3.txt deleted file mode 100644 index c957e422dc..0000000000 --- a/tests/functional/u/useless/useless_super_delegation_py3.txt +++ /dev/null @@ -1,2 +0,0 @@ -useless-parent-delegation:21:4:21:15:UselessSuper.useless:Useless parent delegation in method 'useless':INFERENCE -useless-parent-delegation:34:4:34:16:Ham.__init__:Useless parent delegation in method '__init__':INFERENCE diff --git a/tests/functional/u/useless/useless_super_delegation_py35.py b/tests/functional/u/useless/useless_super_delegation_py35.py deleted file mode 100644 index a405ffb99b..0000000000 --- a/tests/functional/u/useless/useless_super_delegation_py35.py +++ /dev/null @@ -1,46 +0,0 @@ -# pylint: disable=missing-docstring,too-few-public-methods,no-member,unused-argument, useless-object-inheritance - -class NotUselessSuper(object): - - def not_passing_all_params(self, first, *args, second=None, **kwargs): - return super().not_passing_all_params(*args, second, **kwargs) - - -class UselessSuper(object): - - def useless(self, first, *, second=None, **kwargs): # [useless-parent-delegation] - return super().useless(first, second=second, **kwargs) - -# pylint: disable=wrong-import-position -import random -from typing import Any - -class ReturnTypeAny: - choices = ['a', 1, (2, 3)] - - def draw(self) -> Any: - return random.choice(self.choices) - -class ReturnTypeNarrowed(ReturnTypeAny): - choices = [1, 2, 3] - - def draw(self) -> int: - return super().draw() - -class NoReturnType: - choices = ['a', 1, (2, 3)] - - def draw(self): - return random.choice(self.choices) - -class ReturnTypeSpecified(NoReturnType): - choices = ['a', 'b'] - - def draw(self) -> str: # [useless-parent-delegation] - return super().draw() - -class ReturnTypeSame(ReturnTypeAny): - choices = ['a', 'b'] - - def draw(self) -> Any: # [useless-parent-delegation] - return super().draw() diff --git a/tests/functional/u/useless/useless_super_delegation_py35.txt b/tests/functional/u/useless/useless_super_delegation_py35.txt deleted file mode 100644 index 7077b1ccc2..0000000000 --- a/tests/functional/u/useless/useless_super_delegation_py35.txt +++ /dev/null @@ -1,3 +0,0 @@ -useless-parent-delegation:11:4:11:15:UselessSuper.useless:Useless parent delegation in method 'useless':INFERENCE -useless-parent-delegation:39:4:39:12:ReturnTypeSpecified.draw:Useless parent delegation in method 'draw':INFERENCE -useless-parent-delegation:45:4:45:12:ReturnTypeSame.draw:Useless parent delegation in method 'draw':INFERENCE