Skip to content

Commit

Permalink
property-with-parameters properly handles abstract properties
Browse files Browse the repository at this point in the history
Close #3600
  • Loading branch information
PCManticore committed May 14, 2020
1 parent 9e424bb commit dcb5148
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ 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?
===========================
Expand Down
7 changes: 6 additions & 1 deletion pylint/checkers/classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,12 @@ def form_annotations(arguments):
)

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):
Expand Down
14 changes: 14 additions & 0 deletions tests/functional/p/property_with_parameters.py
Original file line number Diff line number Diff line change
@@ -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."""
2 changes: 1 addition & 1 deletion tests/functional/p/property_with_parameters.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit dcb5148

Please sign in to comment.