diff options
| -rw-r--r-- | ChangeLog | 5 | ||||
| -rw-r--r-- | checkers/classes.py | 3 | ||||
| -rw-r--r-- | test/input/func_noerror_abstract_method.py | 20 | ||||
| -rw-r--r-- | test/input/func_noerror_abstract_method_py30.py | 19 |
4 files changed, 46 insertions, 1 deletions
@@ -33,7 +33,10 @@ ChangeLog for Pylint that abstract classes created with `abc` module and with abstract methods are instantied. - * Do not warn about 'return-arg-in-generator' in Python 3.3+. + * Do not warn about 'return-arg-in-generator' in Python 3.3+. + + * Do not warn about 'abstract-method' when the abstract method + is implemented through assignment (#155). 2013-12-22 -- 1.1.0 * Add new check for use of deprecated pragma directives "pylint:disable-msg" diff --git a/checkers/classes.py b/checkers/classes.py index 3f0a22d..42b5761 100644 --- a/checkers/classes.py +++ b/checkers/classes.py @@ -568,6 +568,9 @@ a metaclass class method.'} continue # owner is not this class, it must be a parent class # check that the ancestor's method is not abstract + if method.name in node.locals: + # it is redefined as an attribute or with a descriptor + continue if method.is_abstract(pass_is_abstract=False): self.add_message('W0223', node=node, args=(method.name, owner.name)) diff --git a/test/input/func_noerror_abstract_method.py b/test/input/func_noerror_abstract_method.py new file mode 100644 index 0000000..18228c6 --- /dev/null +++ b/test/input/func_noerror_abstract_method.py @@ -0,0 +1,20 @@ +""" This should not warn about `prop` being abstract in Child """
+
+# pylint: disable=too-few-public-methods,abstract-class-little-used
+
+__revision__ = None
+
+import abc
+
+class Parent(object):
+ """ Class """
+ __metaclass__ = abc.ABCMeta
+
+ @property
+ @abc.abstractmethod
+ def prop(self):
+ """ Abstract """
+
+class Child(Parent):
+ """ No warning for the following. """
+ prop = property(lambda self: 1)
diff --git a/test/input/func_noerror_abstract_method_py30.py b/test/input/func_noerror_abstract_method_py30.py new file mode 100644 index 0000000..c237cb4 --- /dev/null +++ b/test/input/func_noerror_abstract_method_py30.py @@ -0,0 +1,19 @@ +""" This should not warn about `prop` being abstract in Child """
+
+# pylint: disable=too-few-public-methods,abstract-class-little-used,no-init,old-style-class
+
+__revision__ = None
+
+import abc
+
+class Parent(metaclass=abc.ABCMeta):
+ """ Class """
+
+ @property
+ @abc.abstractmethod
+ def prop(self):
+ """ Abstract """
+
+class Child(Parent):
+ """ No warning for the following. """
+ prop = property(lambda self: 1)
|
