Repository: pylint-dev/pylint

Issue:
`property-with-parameters` only cares about non-`self` parameters if they're positional-or-keyword parameters
### Bug description

Pylint's `property-with-parameters` rule checks for `@property`-decorated functions that have non-`self` parameters, on the grounds that additional parameters in a property function can never be used. However, the check currently only seems to care about additional parameters if they are positional-or-keyword parameters. The check does not emit any violations for additional positional-only parameters, additional keyword-only parameters, additional variadic positional parameters, or additional variadic keyword parameters. This seems off to me: defining those additional parameters is just as strange/incorrect as defining additional positional-or-keyword parameters.

To illustrate, only the `a` property in the following example triggers an `R0206` violation, whereas I would expect `R0206` to be emitted on `a`, `b`, `c`, `d` and `e`:

```py
class Foo:
   @property
   def a(self, arg):
       return arg

   @property
   def b(self, arg, /):
      return arg

   @property
   def c(self, *, arg):
      return arg

   @property
   def d(self, *args):
      return args

   @property
   def e(self, **kwargs):
      return kwargs
```

This means that `R0206` is not actually emitted on the motivating example originally given for this check in https://github.com/pylint-dev/pylint/issues/3006#issue-468017491, since that example has an additional variadic keyword parameter (`**kwargs`).


### Command used

```shell
pylint foo.py --disable=W0311,C0114,C0104,C0115,C0116,R0903
```


### Pylint output

```
************* Module foo
foo.py:3:3: R0206: Cannot have defined parameters for properties (property-with-parameters)
```


### Expected output

```
************* Module foo
foo.py:3:3: R0206: Cannot have defined parameters for properties (property-with-parameters)
foo.py:7:3: R0206: Cannot have defined parameters for properties (property-with-parameters)
foo.py:11:3: R0206: Cannot have defined parameters for properties (property-with-parameters)
foo.py:15:3: R0206: Cannot have defined parameters for properties (property-with-parameters)
foo.py:19:3: R0206: Cannot have defined parameters for properties (property-with-parameters)
```

### Pylint version

```shell
pylint 3.1.0
astroid 3.1.0
Python 3.12.2 (main, Feb 15 2024, 19:30:27) [Clang 15.0.0 (clang-1500.1.0.2.5)]
```


### OS / Environment

MacOS

### Additional dependencies

None


Discussion:

Patch:
diff --git a/doc/whatsnew/fragments/9584.false_negative b/doc/whatsnew/fragments/9584.false_negative
new file mode 100644
index 0000000000..41459d6fcc
--- /dev/null
+++ b/doc/whatsnew/fragments/9584.false_negative
@@ -0,0 +1,3 @@
+Fix false negative for ``property-with-parameters`` in the case of parameters which are ``positional-only``, ``keyword-only``, ``variadic positional`` or ``variadic keyword``.
+
+Closes #9584
diff --git a/pylint/checkers/classes/class_checker.py b/pylint/checkers/classes/class_checker.py
index 996c59dcc2..d77465bcd3 100644
--- a/pylint/checkers/classes/class_checker.py
+++ b/pylint/checkers/classes/class_checker.py
@@ -1410,12 +1410,11 @@ def form_annotations(arguments: nodes.Arguments) -> list[str]:
 
     def _check_property_with_parameters(self, node: nodes.FunctionDef) -> None:
         if (
-            node.args.args
-            and len(node.args.args) > 1
+            len(node.args.arguments) > 1
             and decorated_with_property(node)
             and not is_property_setter(node)
         ):
-            self.add_message("property-with-parameters", node=node)
+            self.add_message("property-with-parameters", node=node, confidence=HIGH)
 
     def _check_invalid_overridden_method(
         self,


Test patch:
diff --git a/tests/functional/p/property_with_parameters.py b/tests/functional/p/property_with_parameters.py
index b210bb5015..599d744b4c 100644
--- a/tests/functional/p/property_with_parameters.py
+++ b/tests/functional/p/property_with_parameters.py
@@ -4,8 +4,24 @@
 
 class Cls:
     @property
-    def attribute(self, param, param1): # [property-with-parameters]
-        return param + param1
+    def a(self, arg):  # [property-with-parameters]
+        return arg
+
+    @property
+    def b(self, arg, /):  # [property-with-parameters]
+        return arg
+
+    @property
+    def c(self, *, arg):  # [property-with-parameters]
+        return arg
+
+    @property
+    def d(self, *args):  # [property-with-parameters]
+        return args
+
+    @property
+    def e(self, **kwargs):  # [property-with-parameters]
+        return kwargs
 
 
 class MyClassBase(metaclass=ABCMeta):
diff --git a/tests/functional/p/property_with_parameters.txt b/tests/functional/p/property_with_parameters.txt
index bc07bc6d19..5360e90c0f 100644
--- a/tests/functional/p/property_with_parameters.txt
+++ b/tests/functional/p/property_with_parameters.txt
@@ -1,1 +1,5 @@
-property-with-parameters:7:4:7:17:Cls.attribute:Cannot have defined parameters for properties:UNDEFINED
+property-with-parameters:7:4:7:9:Cls.a:Cannot have defined parameters for properties:HIGH
+property-with-parameters:11:4:11:9:Cls.b:Cannot have defined parameters for properties:HIGH
+property-with-parameters:15:4:15:9:Cls.c:Cannot have defined parameters for properties:HIGH
+property-with-parameters:19:4:19:9:Cls.d:Cannot have defined parameters for properties:HIGH
+property-with-parameters:23:4:23:9:Cls.e:Cannot have defined parameters for properties:HIGH