summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2020-05-14 08:30:03 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2020-05-14 08:53:56 +0200
commitfe7262d625cca6fbf12210c41a9de9a574cacb1a (patch)
tree84e3a1b550bb75493a2e0719d627d01487e6043c
parentf00144fb8faa81e1ce42516c2f58eb9fc797f7bd (diff)
downloadpylint-git-fe7262d625cca6fbf12210c41a9de9a574cacb1a.tar.gz
`property-with-parameters` properly handles abstract properties
Close #3600
-rw-r--r--ChangeLog10
-rw-r--r--pylint/checkers/classes.py7
-rw-r--r--tests/functional/p/property_with_parameters.py14
-rw-r--r--tests/functional/p/property_with_parameters.txt2
4 files changed, 31 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 33d3054ac..4492c007c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -21,6 +21,16 @@ Release date: TBA
* Add `super-with-arguments` check for flagging instances of Python 2 style super calls.
+What's New in Pylint 2.5.3?
+===========================
+
+Release date: TBA
+
+* `property-with-parameters` properly handles abstract properties
+
+ Close #3600
+
+
What's New in Pylint 2.5.2?
===========================
diff --git a/pylint/checkers/classes.py b/pylint/checkers/classes.py
index 775f8aad2..bbbd60210 100644
--- a/pylint/checkers/classes.py
+++ b/pylint/checkers/classes.py
@@ -1109,7 +1109,12 @@ a metaclass class method.",
)
def _check_property_with_parameters(self, node):
- if node.args.args and len(node.args.args) > 1 and decorated_with_property(node):
+ if (
+ node.args.args
+ and len(node.args.args) > 1
+ and decorated_with_property(node)
+ and not is_property_setter(node)
+ ):
self.add_message("property-with-parameters", node=node)
def _check_invalid_overridden_method(self, function_node, parent_function_node):
diff --git a/tests/functional/p/property_with_parameters.py b/tests/functional/p/property_with_parameters.py
index 2f521991f..9f746f75f 100644
--- a/tests/functional/p/property_with_parameters.py
+++ b/tests/functional/p/property_with_parameters.py
@@ -1,7 +1,21 @@
# pylint: disable=missing-docstring, too-few-public-methods
+from abc import ABCMeta, abstractproperty
class Cls:
@property
def attribute(self, param, param1): # [property-with-parameters]
return param + param1
+
+
+class MyClassBase(metaclass=ABCMeta):
+ """MyClassBase."""
+
+ @abstractproperty
+ def example(self):
+ """Getter."""
+
+ @abstractproperty
+ @example.setter
+ def example(self, value):
+ """Setter."""
diff --git a/tests/functional/p/property_with_parameters.txt b/tests/functional/p/property_with_parameters.txt
index 325d89306..617ce3c31 100644
--- a/tests/functional/p/property_with_parameters.txt
+++ b/tests/functional/p/property_with_parameters.txt
@@ -1 +1 @@
-property-with-parameters:6:Cls.attribute:Cannot have defined parameters for properties
+property-with-parameters:7:Cls.attribute:Cannot have defined parameters for properties