質問
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モジュールに由来するためだと思いました。クラスの1つからサブクラスを作成したり、純粋なpythonである SocketServer.BaseServer
などのサブクラスを作成しても警告は表示されません。しかし、Cモジュールにある smbus.SMBus
からサブクラス化しても、警告は表示されません。
W0231を無効にする以外の回避策を知っている人はいますか?
解決
新しいスタイルの super
呼び出しを使用してみてください:
class Foo(ctypes.BigEndianStructure):
def __init__(self):
super(Foo, self).__init__()
所属していません StackOverflow