【问题标题】:Eclipse Pydev: Supress no-self errors in python wrappers generated with swigEclipse Pydev:抑制使用 swig 生成的 python 包装器中的 no-self 错误
【发布时间】:2011-01-26 17:58:46
【问题描述】:

当使用 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 生成的文件收到错误警告。显然第二个也不是很好,因为我必须手动完成,每次再次生成文件时,所有#@NoSelfs 都会消失。

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

谢谢

【问题讨论】:

    标签: python swig pydev


    【解决方案1】:

    根据文档,任何带有注释的文件

    #@PydevCodeAnalysisIgnore
    

    内部不会被分析。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-04-05
      相关资源
      最近更新 更多