Eclipse Pydev:抑制使用 swig 生成的 python 包装器中的无自我错误

发布于 2024-08-24 16:36:49 字数 708 浏览 4 评论 0原文

当使用 swig 生成 python 包装器时,生成的 python 文件中的 python 包装器类没有显式的 self 参数,例如如下所示:

class PySwigIterator(_object):
    def value(*args): return _spatiotemporalnmf.PySwigIterator_value(*args)
    def incr(*args): return _spatiotemporalnmf.PySwigIterator_incr(*args)
    def decr(*args): return _spatiotemporalnmf.PySwigIterator_decr(*args)
    def distance(*args): return _spatiotemporalnmf.PySwigIterator_distance(*args)

我正在使用 eclipse 插件 Pydev 进行开发。当 Pydev 检测到没有显式 self 参数的方法时,它总是显示错误。我知道有两种方法可以消除错误:首先,在 Pydev 首选项中禁用整个项目的错误检查。其次,在每一个有错误的行中添加#@NoSelf。我不想使用第一个,因为我仍然想获得非 swig 生成的文件的错误警告。显然第二个也不是很好,因为我必须手动完成,每次再次生成文件时,所有 #@NoSelf 都会消失。

我现在的问题是,有没有更好的方法来实现这一目标?

谢谢

when generating python wrappers with swig the python wrapper classes in the generated python file do not have an explicit self parameter, for example see below:

class PySwigIterator(_object):
    def value(*args): return _spatiotemporalnmf.PySwigIterator_value(*args)
    def incr(*args): return _spatiotemporalnmf.PySwigIterator_incr(*args)
    def decr(*args): return _spatiotemporalnmf.PySwigIterator_decr(*args)
    def distance(*args): return _spatiotemporalnmf.PySwigIterator_distance(*args)

I am developing with the eclipse pluging Pydev. Pydev always shows an error when it detects a method without explicit self parameter. I am aware of two methods to get rid of the errors: First, disable error checking for the whole project in the Pydev preferences. Second, add a #@NoSelf to every line with an error. I don't want to use the first one, because I still want to get error warnings for my non-swig-generated files. Obviously the second one is also not very good, because I would have to do it by hand and every time I generate the file again, all #@NoSelfs will be gone.

My Question now is, is there a better way to achieve this?

Thanks

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

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

发布评论

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

评论(1

々眼睛长脚气 2024-08-31 16:36:49

从文档来看,任何带有注释的文件

#@PydevCodeAnalysisIgnore

都不会被分析。

因此,您只需将其添加到所有 SWIG 生成的文件中,就可以了。它只是一个需要更改的地方,您甚至可以编写一个非常小的处理器来自动添加它。

As from the documentation, any file with the comment

#@PydevCodeAnalysisIgnore

inside will not be analyzed.

Therefore, you just need to add it to all SWIG-generated files, and you should be OK. It is just one place to change, and you could even write a very small processor that will add it automatically.

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