diff options
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | pylint/checkers/classes.py | 3 | ||||
-rw-r--r-- | pylint/test/functional/no_self_use.py | 14 |
3 files changed, 17 insertions, 2 deletions
@@ -45,6 +45,8 @@ ChangeLog for Pylint crashed when it encountered a bytes string with a .format method called. + * Don't warn about no-self-use for builtin properties. + 2015-03-14 -- 1.4.3 diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py index 2bd7cc1dc..080abd97c 100644 --- a/pylint/checkers/classes.py +++ b/pylint/checkers/classes.py @@ -550,7 +550,8 @@ a metaclass class method.'} if (self._meth_could_be_func and node.type == 'method' and not node.name in PYMETHODS and not (node.is_abstract() or - overrides_a_method(class_node, node.name)) + overrides_a_method(class_node, node.name) or + decorated_with_property(node)) and class_node.type != 'interface'): self.add_message('no-self-use', node=node) diff --git a/pylint/test/functional/no_self_use.py b/pylint/test/functional/no_self_use.py index 9c432f923..ab3b1ba88 100644 --- a/pylint/test/functional/no_self_use.py +++ b/pylint/test/functional/no_self_use.py @@ -1,4 +1,4 @@ -# pylint: disable=R0903,W0232 +# pylint: disable=R0903,W0232,missing-docstring """test detection of method which could be a function""" from __future__ import print_function @@ -58,3 +58,15 @@ class Sub1(Super): def __cmp__(self, other): """no i can not be a function""" print(42) + + +class Prop(object): + + @property + def count(self): + """Don't emit no-self-use for properties. + + They can't be functions and they can be part of an + API specification. + """ + return 42 |