Python 使自动生成的模块成员对PyDev/PyLint静态分析可见

Python 使自动生成的模块成员对PyDev/PyLint静态分析可见,python,python-2.7,dynamic,pydev,static-analysis,Python,Python 2.7,Dynamic,Pydev,Static Analysis,如果我正在设计一个包含动态生成成员的Python模块,有没有办法帮助PyDev/PyLint提供一些信息?(而不是要求模块的最终用户忽略错误或警告) 这里有一个例子。我得到了所有UInt8Col、UInt16Col、UInt32Col等类的错误,因为它们在静态分析中是不可见的,我可以通过在应用程序代码的注释中添加@UndefinedVariable来抑制这些错误。但我想知道有没有更好的办法 def _generate_col_classes(): """Generate all colu

如果我正在设计一个包含动态生成成员的Python模块,有没有办法帮助PyDev/PyLint提供一些信息?(而不是要求模块的最终用户忽略错误或警告)

这里有一个例子。我得到了所有
UInt8Col
UInt16Col
UInt32Col
等类的错误,因为它们在静态分析中是不可见的,我可以通过在应用程序代码的注释中添加
@UndefinedVariable
来抑制这些错误。但我想知道有没有更好的办法

def _generate_col_classes():
    """Generate all column classes."""

    # Abstract classes are not in the class map.
    cprefixes = ['Int', 'UInt', 'Float', 'Time']
    for (kind, kdata) in atom.atom_map.iteritems():
        if hasattr(kdata, 'kind'):  # atom class: non-fixed item size
            atomclass = kdata
            cprefixes.append(atomclass.prefix())
        else:  # dictionary: fixed item size
            for atomclass in kdata.itervalues():
                cprefixes.append(atomclass.prefix())

    # Bottom-level complex classes are not in the type map, of course.
    # We still want the user to get the compatibility warning, though.
    cprefixes.extend(['Complex32', 'Complex64', 'Complex128'])
    if hasattr(atom, 'Complex192Atom'):
        cprefixes.append('Complex192')
    if hasattr(atom, 'Complex256Atom'):
        cprefixes.append('Complex256')

    for cprefix in cprefixes:
        newclass = Col._subclass_from_prefix(cprefix)
        yield newclass

# Create all column classes.
for _newclass in _generate_col_classes():
    exec('%s = _newclass' % _newclass.__name__)
del _newclass

PyDev/PyLint可能是按源代码行号定位属性的。当您动态生成这些成员时,我希望PyDev/PyLint没有胶水,代码中的哪一行是指向的。有一些方法可以在不调用
exec
的情况下创建新类,例如:无论如何,我认为这并不能解决您的问题。