Python Pylint:如何使用属性类指定自定义属性装饰器?
Pylint报告一个错误E0202方法,该方法对于使用自定义属性装饰器的Python代码是隐藏的。我尝试使用属性类选项失败 这里是道具 和testimport.py: 使用Python 2.7.13运行代码会产生预期的结果:Python Pylint:如何使用属性类指定自定义属性装饰器?,python,properties,pylint,Python,Properties,Pylint,Pylint报告一个错误E0202方法,该方法对于使用自定义属性装饰器的Python代码是隐藏的。我尝试使用属性类选项失败 这里是道具 和testimport.py: 使用Python 2.7.13运行代码会产生预期的结果: $ python test.py ('attr', 'myattr') ('value', 'myvalue') Pylint 1.6.5报告自定义属性的错误,但不报告常规属性的错误: $ pylint -E --property-classes=props.myprop
$ python test.py
('attr', 'myattr')
('value', 'myvalue')
Pylint 1.6.5报告自定义属性的错误,但不报告常规属性的错误:
$ pylint -E --property-classes=props.myproperty testimport.py
No config file found, using default configuration
************* Module testimport
E: 20, 4: An attribute defined in testimport line 29 hides this method (method-hidden)
self.myattr = 'myvalue'
第29行使用自定义属性的setter:
$ pylint -E --property-classes=props.myproperty testimport.py
No config file found, using default configuration
************* Module testimport
E: 20, 4: An attribute defined in testimport line 29 hides this method (method-hidden)
self.myattr = 'myvalue'
pylint的正确选项是什么?或者这是一个假阳性?不确定我是否遇到了与您相同的问题,因为我遇到了一个无会员错误 我正在使用的装饰器名为@memoized_property,我通过将其添加到我的pylintrc中解决了这个问题:
init-hook="import astroid.bases; astroid.bases.POSSIBLE_PROPERTIES.add('memoized_property')"
还可以将其作为参数传递给pylint:-init hook=import astroid.base;星象。基础。可能的属性。添加“记忆属性”