pylint误报为超类__init__

bst*_*rre 2 python pylint

如果我从中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)
Run Code Online (Sandbox Code Playgroud)

起初我以为这是因为Structure来自C模块.如果我从我的一个类中继承,或者说,SocketServer.BaseServer这是纯Python ,我不会收到警告.但是我也没有得到警告,如果我是子类smbus.SMBus,这是在C模块中.

有人知道除了禁用W0231之外的解决方法吗?

jkp*_*jkp 6

尝试使用新式super调用:

class Foo(ctypes.BigEndianStructure):
    def __init__(self):
        super(Foo, self).__init__()
Run Code Online (Sandbox Code Playgroud)