Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ What's New in Pylint 2.6.1?

Release date: TBA

* Fix ``useless-super-delegation`` false positive when default keyword argument is a dictionnary.

Close #3773

What's New in Pylint 2.6.0?
===========================

Expand Down
2 changes: 2 additions & 0 deletions doc/whatsnew/2.6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ New checkers
Other Changes
=============

* Fix false positive message ``useless-super-delegation`` when default keyword argument is a dictionnary.

* `bad-continuation` and `bad-whitespace` have been removed. `black` or another formatter can help you with this better than Pylint

* The `no-space-check` option has been removed, it's no longer possible to consider empty line like a `trailing-whitespace` by using clever options.
Expand Down
1 change: 1 addition & 0 deletions pylint/checkers/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ def _has_different_parameters_default_value(original, overridden):
astroid.ClassDef: "name",
astroid.Tuple: "elts",
astroid.List: "elts",
astroid.Dict: "items",
}
handled_types = tuple(
astroid_type for astroid_type in astroid_type_compared_attr
Expand Down
12 changes: 11 additions & 1 deletion tests/functional/u/useless_super_delegation.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# pylint: disable=missing-docstring, no-member, no-self-use, bad-super-call
# pylint: disable=too-few-public-methods, unused-argument, invalid-name, too-many-public-methods
# pylint: disable=line-too-long, useless-object-inheritance, arguments-out-of-order
# pylint: disable=super-with-arguments
# pylint: disable=super-with-arguments, dangerous-default-value

def not_a_method(param, param2):
return super(None, None).not_a_method(param, param2)
Expand Down Expand Up @@ -49,6 +49,9 @@ def with_default_argument_int(self, first, default_arg=42):
def with_default_argument_tuple(self, first, default_arg=()):
pass

def with_default_argument_dict(self, first, default_arg={}):
pass

def with_default_arg_ter(self, first, default_arg="has_been_changed"):
super().with_default_arg_ter(first, default_arg)

Expand Down Expand Up @@ -160,6 +163,10 @@ 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'}):
# 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)

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.
Expand Down Expand Up @@ -226,6 +233,9 @@ def with_default_argument_int(self, first, default_arg=42): # [useless-super-del
def with_default_argument_tuple(self, first, default_arg=()): # [useless-super-delegation]
super(UselessSuper, self).with_default_argument_tuple(first, default_arg)

def with_default_argument_dict(self, first, default_arg={}): # [useless-super-delegation]
super(UselessSuper, self).with_default_argument_dict(first, default_arg)

def __init__(self): # [useless-super-delegation]
super(UselessSuper, self).__init__()

Expand Down
35 changes: 18 additions & 17 deletions tests/functional/u/useless_super_delegation.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
useless-super-delegation:191:UselessSuper.equivalent_params:Useless super delegation in method 'equivalent_params'
useless-super-delegation:194:UselessSuper.equivalent_params_1:Useless super delegation in method 'equivalent_params_1'
useless-super-delegation:197:UselessSuper.equivalent_params_2:Useless super delegation in method 'equivalent_params_2'
useless-super-delegation:200:UselessSuper.equivalent_params_3:Useless super delegation in method 'equivalent_params_3'
useless-super-delegation:203:UselessSuper.equivalent_params_4:Useless super delegation in method 'equivalent_params_4'
useless-super-delegation:206:UselessSuper.equivalent_params_5:Useless super delegation in method 'equivalent_params_5'
useless-super-delegation:209:UselessSuper.equivalent_params_6:Useless super delegation in method 'equivalent_params_6'
useless-super-delegation:212:UselessSuper.with_default_argument:Useless super delegation in method 'with_default_argument'
useless-super-delegation:216:UselessSuper.without_default_argument:Useless super delegation in method 'without_default_argument'
useless-super-delegation:219:UselessSuper.with_default_argument_none:Useless super delegation in method 'with_default_argument_none'
useless-super-delegation:223:UselessSuper.with_default_argument_int:Useless super delegation in method 'with_default_argument_int'
useless-super-delegation:226:UselessSuper.with_default_argument_tuple:Useless super delegation in method 'with_default_argument_tuple'
useless-super-delegation:229:UselessSuper.__init__:Useless super delegation in method '__init__'
useless-super-delegation:232:UselessSuper.with_default_arg:Useless super delegation in method 'with_default_arg'
useless-super-delegation:235:UselessSuper.with_default_arg_bis:Useless super delegation in method 'with_default_arg_bis'
useless-super-delegation:238:UselessSuper.with_default_arg_ter:Useless super delegation in method 'with_default_arg_ter'
useless-super-delegation:241:UselessSuper.with_default_arg_quad:Useless super delegation in method 'with_default_arg_quad'
useless-super-delegation:198:UselessSuper.equivalent_params:Useless super delegation in method 'equivalent_params'
useless-super-delegation:201:UselessSuper.equivalent_params_1:Useless super delegation in method 'equivalent_params_1'
useless-super-delegation:204:UselessSuper.equivalent_params_2:Useless super delegation in method 'equivalent_params_2'
useless-super-delegation:207:UselessSuper.equivalent_params_3:Useless super delegation in method 'equivalent_params_3'
useless-super-delegation:210:UselessSuper.equivalent_params_4:Useless super delegation in method 'equivalent_params_4'
useless-super-delegation:213:UselessSuper.equivalent_params_5:Useless super delegation in method 'equivalent_params_5'
useless-super-delegation:216:UselessSuper.equivalent_params_6:Useless super delegation in method 'equivalent_params_6'
useless-super-delegation:219:UselessSuper.with_default_argument:Useless super delegation in method 'with_default_argument'
useless-super-delegation:223:UselessSuper.without_default_argument:Useless super delegation in method 'without_default_argument'
useless-super-delegation:226:UselessSuper.with_default_argument_none:Useless super delegation in method 'with_default_argument_none'
useless-super-delegation:230:UselessSuper.with_default_argument_int:Useless super delegation in method 'with_default_argument_int'
useless-super-delegation:233:UselessSuper.with_default_argument_tuple:Useless super delegation in method 'with_default_argument_tuple'
useless-super-delegation:236:UselessSuper.with_default_argument_dict:Useless super delegation in method 'with_default_argument_dict'
useless-super-delegation:239:UselessSuper.__init__:Useless super delegation in method '__init__'
useless-super-delegation:242:UselessSuper.with_default_arg:Useless super delegation in method 'with_default_arg'
useless-super-delegation:245:UselessSuper.with_default_arg_bis:Useless super delegation in method 'with_default_arg_bis'
useless-super-delegation:248:UselessSuper.with_default_arg_ter:Useless super delegation in method 'with_default_arg_ter'
useless-super-delegation:251:UselessSuper.with_default_arg_quad:Useless super delegation in method 'with_default_arg_quad'