diff options
| author | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-04-06 22:26:47 +0300 |
|---|---|---|
| committer | Claudiu Popa <cpopa@cloudbasesolutions.com> | 2015-04-06 22:26:47 +0300 |
| commit | 80581e989a94f693fef27561e3fcaada7295b7b6 (patch) | |
| tree | 0e935ae6223c293207762725ea709749491f787b | |
| parent | e753a21c82b0b247644d422c99ae0752518a1e4e (diff) | |
| download | pylint-80581e989a94f693fef27561e3fcaada7295b7b6.tar.gz | |
Don't warn about no-self-use for builtin properties.
| -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 2bd7cc1..080abd9 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 9c432f9..ab3b1ba 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 |
