diff options
-rw-r--r-- | pylint/checkers/classes.py | 11 | ||||
-rw-r--r-- | pylint/test/functional/no_self_use_py3.py | 12 | ||||
-rw-r--r-- | pylint/test/functional/no_self_use_py3.rc | 2 | ||||
-rw-r--r-- | pylint/test/functional/no_self_use_py3.txt | 1 |
4 files changed, 25 insertions, 1 deletions
diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py index 0fc0fae..c628e94 100644 --- a/pylint/checkers/classes.py +++ b/pylint/checkers/classes.py @@ -140,6 +140,14 @@ def _is_attribute_property(name, klass): return True return False +def _has_super_call(fundef_node): + for call in fundef_node.nodes_of_class(astroid.Call): + func = call.func + if (isinstance(func, astroid.Name) and + func.name == 'super' and + not call.args): + return True + return False MSGS = { 'F0202': ('Unable to check methods signature (%s / %s)', @@ -545,7 +553,8 @@ a metaclass class method.'} and not node.name in PYMETHODS and not (node.is_abstract() or overrides_a_method(class_node, node.name) or - decorated_with_property(node))): + decorated_with_property(node) or + (six.PY3 and _has_super_call(node)))): self.add_message('no-self-use', node=node) def visit_attribute(self, node): diff --git a/pylint/test/functional/no_self_use_py3.py b/pylint/test/functional/no_self_use_py3.py new file mode 100644 index 0000000..f401508 --- /dev/null +++ b/pylint/test/functional/no_self_use_py3.py @@ -0,0 +1,12 @@ +# pylint: disable=missing-docstring,no-init,unused-argument,invalid-name,too-few-public-methods + +class A: + def __init__(self): + self.store = {} + + def get(self, key, default=None): + return self.store.get(key, default) + +class B(A): + def get_memo(self, obj): + return super().get(obj) diff --git a/pylint/test/functional/no_self_use_py3.rc b/pylint/test/functional/no_self_use_py3.rc new file mode 100644 index 0000000..a2ab06c --- /dev/null +++ b/pylint/test/functional/no_self_use_py3.rc @@ -0,0 +1,2 @@ +[testoptions] +min_pyver=3.0
\ No newline at end of file diff --git a/pylint/test/functional/no_self_use_py3.txt b/pylint/test/functional/no_self_use_py3.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/pylint/test/functional/no_self_use_py3.txt @@ -0,0 +1 @@ + |