代码之家  ›  专栏  ›  技术社区  ›  bstpierre Edgar Aviles

超类_init的pylint假阳性__

  •  2
  • bstpierre Edgar Aviles  · 技术社区  · 15 年前

    ctypes.BigEndianStructure ,pylint警告如果我不打电话 BigEndianStructure.__init__() . 很好,但如果我修复了代码,pylint仍然警告:

    import ctypes
    
    class Foo(ctypes.BigEndianStructure):
        def __init__(self):
            ctypes.BigEndianStructure.__init__(self)
    
    $ pylint mymodule.py
    C:  1: Missing docstring
    C:  3:Foo: Missing docstring
    W:  4:Foo.__init__: __init__ method from base class 'Structure' is not called
    W:  4:Foo.__init__: __init__ method from base class 'BigEndianStructure' is not called
    R:  3:Foo: Too few public methods (0/2)
    

    起初我认为这是因为结构来自C模块。如果我从我的一个类中创建子类,或者说, SocketServer.BaseServer 这是纯python。但是如果我从 smbus.SMBus ,它位于C模块中。

    1 回复  |  直到 6 年前
        1
  •  6
  •   jkp    15 年前

    尝试使用新样式 super 电话:

    class Foo(ctypes.BigEndianStructure):
        def __init__(self):
            super(Foo, self).__init__()