I am working on a class with properties, but we ran into an unpleasant problem with pylint (0.25.1). In the code below, we define a class with a property that was introduced in python 2.6. However, pylint whines that a __init__ self.aProperty method will overwrite a specific method called aProperty. I also inserted console output and pylint message output.
Is this the case "report it to pylint developers" or is this the wrong code (example)?
"""example module""" class Example(object): """example class""" @property def aProperty(self): """get""" print "using getter" return self._myPropertyValue @aProperty.setter def aProperty(self, value): """set""" print "using setter" self._myPropertyValue = value def secondPublicMethodToIgnorePylintWarning(self): """dummy""" return self.aProperty def __init__(self): """init""" self._myPropertyValue = None self.aProperty = "ThisStatementWillRaise E0202" anExample = Example() print anExample.aProperty anExample.aProperty = "Second binding" print anExample.aProperty
Console output:
using setter
using getter
ThisStatementWillRaise E0202
using the setter
using getter
Second commitment
Peeling output:
E0202: 7.4: Example.aProperty: the attribute touched on line test1 26 hides this method
E0202: 13.4: Example.aProperty: the attribute touched on line test1 26 hides this method
source share