pylint bug - E1101 &使用 @property + 时的 E0102 @foo.setter
我注意到 pylint 不能很好地处理以下情况:
@property
def foo(self):
return self._bar.foo
@foo.setter
def foo(self, foo_val):
self._bar.foo = foo_val
尽管它是自 python2.6 以来完全有效的 case 语法
它说我定义了 foo 两次,并且不理解“.setter”语法(给出 E1101 和 E0102)。
有没有无需更改代码的解决方法?我不想禁用这些错误,因为它们对其他地方很重要。
我可以使用其他工具来更好地处理它吗?我已经检查过 pyflakes,它的行为方式相同。 PyDev 的代码分析似乎可以更好地处理这种特定情况,但它不会检查约定、重构和 pylint 所做的其他很酷的功能,而且我无法从外部脚本运行它(或者我可以吗?)
谢谢!
I noticed pylint doesn't handle well the case of:
@property
def foo(self):
return self._bar.foo
@foo.setter
def foo(self, foo_val):
self._bar.foo = foo_val
Though it's a perfectly valid case syntax since python2.6
It says I defined foo twice, and doesn't understand the ".setter" syntax (Gives E1101 & E0102).
Is there a workaround for that without having to change the code? I don't want to disable the errors as they are important for other places.
Is there any other tool I can use that handles it better? I already checked pyflakes and it behaves the same way. PyDev's code analysis seems to handle this specific case better, but it doesn't check for conventions, refactoring, and other cool features pylint does, and I can't run it from an external script (or can I??)
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您不想全局禁用错误,则可以针对这些特定行禁用它们,例如:
If you don't want to disable the errors globally, you can disable them for these specific lines, for example:
这是 pylint 项目的票证 http://www.logilab.org/ticket/51222。监控它的状态。
This is ticket http://www.logilab.org/ticket/51222 on the pylint project. Monitor it's status.
呵呵。恼人的。我能找到的所有主要工具(pyflakes、pylint、pychecker)都存在这个问题。看起来问题是从字节码开始的,但我无法让
dis
为我提供对象属性的任何字节码。如果您使用以下语法,您的情况似乎会更好:
这是 不错的博客文章。哈哈-引用:
Huh. Annoying. And all the major tools I could find (pyflakes, pylint, pychecker) exhibit this problem. It looks like the problem starts in the byte code, but I can't get
dis
to give me any byte code for object properties.It looks like you would be better off if you used this syntax:
Here's a nice blog article on it. LOL-quote:
这是报告为 pyflakes 中的错误,并且似乎已在当前主干中修复。所以我猜答案(现在)是:pyflakes!
This was reported as a bug in pyflakes, and it appears to be fixed in current trunk. So I guess the answer (now) is: pyflakes!