如果我从ctypes.BigEndianStructure
派生一个班级,如果我不拨打BigEndianStructure.__init__()
,pylint会发出警告。很好,但是如果我修复了我的代码,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)
起初我认为这是因为Structure来自C模块。如果我从我的一个类中继承,或者说SocketServer.BaseServer
是纯python,我就不会收到警告。但是,如果我从{C}模块中的smbus.SMBus
进行子类化,我也不会收到警告。
除了禁用W0231之外,任何人都知道解决方法吗?
答案 0 :(得分:6)
尝试使用新式super
来电:
class Foo(ctypes.BigEndianStructure):
def __init__(self):
super(Foo, self).__init__()