Open
Description
Bug description
Classes Decorators
, Functions
, Functions2
are functionally equivalent and Descriptors
is closely similar. Nevertheless pylint doesn't complain with R0903 (too-few-public-methods) issues about Decorators
class. But complains about others:
class Decorators:
@property
def id(self):
pass
@property
def name(self):
pass
class Functions:
id = property(lambda self: None)
name = property(lambda self: None)
def my_property():
def getter(_self):
pass
return property(getter)
class Functions2:
id = my_property()
name = my_property()
class Descriptor:
def __get__(self, instance, owner=None):
pass
class Descriptors:
id = Descriptor()
name = Descriptor()
All approaches except Decorators provide a way to avoid boiler-plate for properties.
Configuration
Command used
pylint --disable=C ./property.py
Pylint output
************* Module property
property.py:12:0: R0903: Too few public methods (0/2) (too-few-public-methods)
property.py:24:0: R0903: Too few public methods (0/2) (too-few-public-methods)
property.py:37:0: R0903: Too few public methods (0/2) (too-few-public-methods)
Expected behavior
pylint recognizes all the ways to define a property and doesn't raise R0903 issues
Pylint version
pylint 3.3.6
astroid 3.3.9
Python 3.12.7 (main, Nov 12 2024, 06:04:35) [GCC 12.2.0]
OS / Environment
No response