Skip to content

Commit dcb5148

Browse files
committed
property-with-parameters properly handles abstract properties
Close #3600
1 parent 9e424bb commit dcb5148

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ What's New in Pylint 2.5.3?
77

88
Release date: TBA
99

10+
* `property-with-parameters` properly handles abstract properties
11+
12+
Close #3600
13+
1014

1115
What's New in Pylint 2.5.2?
1216
===========================

pylint/checkers/classes.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,12 @@ def form_annotations(arguments):
11091109
)
11101110

11111111
def _check_property_with_parameters(self, node):
1112-
if node.args.args and len(node.args.args) > 1 and decorated_with_property(node):
1112+
if (
1113+
node.args.args
1114+
and len(node.args.args) > 1
1115+
and decorated_with_property(node)
1116+
and not is_property_setter(node)
1117+
):
11131118
self.add_message("property-with-parameters", node=node)
11141119

11151120
def _check_invalid_overridden_method(self, function_node, parent_function_node):
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
# pylint: disable=missing-docstring, too-few-public-methods
2+
from abc import ABCMeta, abstractproperty
23

34

45
class Cls:
56
@property
67
def attribute(self, param, param1): # [property-with-parameters]
78
return param + param1
9+
10+
11+
class MyClassBase(metaclass=ABCMeta):
12+
"""MyClassBase."""
13+
14+
@abstractproperty
15+
def example(self):
16+
"""Getter."""
17+
18+
@abstractproperty
19+
@example.setter
20+
def example(self, value):
21+
"""Setter."""
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
property-with-parameters:6:Cls.attribute:Cannot have defined parameters for properties
1+
property-with-parameters:7:Cls.attribute:Cannot have defined parameters for properties

0 commit comments

Comments
 (0)