如何告诉 Pychecker 忽略导入的库?
我导入到 python 项目中的模块之一在 Pychecker 下触发了许多警告。修复这个外部模块并不是真正的选择,所以我想告诉 Pychecker 忽略它。
有谁知道该怎么做?我确信这是可能的,而且可能非常简单,但在谷歌搜索了一段时间后,我没有找到任何文档或示例。
谢谢, Sam
编辑:不幸的是,我无法用“pychecker”标记此标签,因为该标签尚不存在,而且我的代表太低,无法创建。
编辑 2 额外问题:pychecker 是否会检查被忽略的模块,并且不打印它找到的任何内容?或者您是否通过忽略某些模块来获得一些加速?
One of the modules I import into my python project triggers lots of warnings under Pychecker. Fixing up this external module isn't really an option, so I want to tell Pychecker to ignore it.
Does anyone know how to do this? I'm sure it's possible, and probably quite simple, but after trawling Google for a while I've not found any documentation or examples.
Thanks,
Sam
Edit: I can't tag this with 'pychecker' unfortunately as that tag doesn't exist yet and my rep is too low to create.
Edit 2 Bonus extra question: does pychecker check ignored modules anyway, and just not print anything it finds? or do you get some speedup by ignoring some modules?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据 文档,
IOW,在您的 .pycheckrc 中,如果这个麻烦的模块名为
foobar
,您将拥有...
表示的所有您想要的抑制选项。使用 pychecker -h 获取所有选项的列表;我认为'limit=0'
会满足您的要求(该模块最多显示 0 个警告,即无;-),但您可能希望更有选择性(毕竟,您只需在 .pycheckrc 中一次性编写此代码,而不是在调用 pychecker 的每个位置上编写...这是方便的pycheckrc 方法!)。Per the docs,
IOW, in your .pycheckrc, if the troublesome module is named
foobar
, you'll havewhere the
...
means, all the suppress options you want. Usepychecker -h
to get a list of all the options; I think'limit=0'
will do what you're asking for (show a max of 0 warnings for that module, i.e., none;-), but you may want to be a bit more selective (after all you only have to write this once and for all in.pycheckrc
, not on every spot from which you're callingpychecker
... which is the convenience of the pycheckrc approach!).我找到了另一个选项 - 您可以使用 -b 标志将其列入黑名单。例如,
我不确定,但我认为这无论如何都会检查导入的模块,但只是不打印警告。使用 -b 标志肯定不会比不使用 -b 标志更快 - 尽管至少警告消失了:-)
I've found another option - you can blacklist using the -b flag. Eg
I'm not sure, but I think this checks the imported modules anyway, but just doesn't print the warnings. It certainly doesn't seem any faster with the -b flag than without - though at least the warnings are gone :-)
关于额外的问题:
我正在考虑是否值得将 pychecker 更改为根本不查看黑名单模块,或者使其可以仅反汇编一个文件(例如,用于在编辑器中集成)。
On the bonus extra question:
I am considering if it is worth it to change pychecker to not even look at blacklisted modules at all, or make it possible to only disassemble the one file (for integration in an editor for example).