pylint“disable-msg”的简写注释评论?

发布于 2024-11-11 05:52:14 字数 264 浏览 3 评论 0原文

我在 Django 项目上使用 pylint,我发现自己经常复制粘贴这一行:
# pylint:disable-msg=E1101 因为 pylint 的工作方式

我对此很满意,但如果我不必每次都复制粘贴,那就更好了。有什么方法可以定义快捷方式或其他东西吗?或者总的来说,你们是如何应对这个问题的?

I'm using pylint on a Django project and I'm finding myself frequently copy-pasting this line:
# pylint: disable-msg=E1101 because of the way pylint works.

I'm fine with this, but it would be nicer if I don't have to copy-paste this every time. Is there are way I can define a shortcut or something? Or in general, how are you guys coping with this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小矜持 2024-11-18 05:52:14

不确定我的理解是否正确,但如果您想要的只是快速轻松地放置此“禁用”注释的方法 - 您可以在 Eclipse 中使用模板或 Pycharm 中的实时模板或其他类似的东西(如宏)在任何其他好的IDE。

但是,为什么不使用其他解决方案,这样您就不需要一直使用“pylitnt:disable-msg”呢?例如,您可以在 rcfile 中使用“ generated-members”设置来省略 django 生成的那些类字段 - 嗯,实际上正是这样 您提到的帖子中提出了一个答案

顺便说一下,pylint 还有一个选项“zope”,它可以禁用 Zope 通常生成的所有字段的 E1101 错误消息。您可以尝试提交 pylint 的功能请求,为 Django 添加类似的设置 - 这个选项对我来说听起来很合乎逻辑,只要已经有类似的案例。请参阅:http://www.logilab.org/card/pylintfeatures#id25

Not sure I get you right, but if what you want is only a way to put this "disable" comments quick and easy - you can use templates in Eclipse or Live Templates in Pycharm or other similar thing (like macros) in any other good IDE.

However, why not using other solutions, so that you won't need to use "pylitnt: disable-msg" all the time? For example, you could use "generated-members" setting in rcfile to omit those class fields that are generated by django - well, actually exactly the way one of the answers proposes in the post you mention.

By the way, pylint has also an option "zope", which disables E1101 error message for all fields that are usually being generated by Zope. You could try submitting feature request for pylint to add similar setting for Django - this option sounds logical for me, as long as there is a similar case already. See this: http://www.logilab.org/card/pylintfeatures#id25

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文