Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/282.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 超类_init的pylint假阳性___Python_Pylint - Fatal编程技术网

Python 超类_init的pylint假阳性__

Python 超类_init的pylint假阳性__,python,pylint,Python,Pylint,如果我从ctypes.bigendianstruct派生一个类,pylint会发出警告,如果我不调用bigendianstruct.\uuu init\uuu()。很好,但如果我修复了代码,pylint仍然警告: import ctypes class Foo(ctypes.BigEndianStructure): def __init__(self): ctypes.BigEndianStructure.__init__(self) $ pylint mymodul

如果我从
ctypes.bigendianstruct
派生一个类,pylint会发出警告,如果我不调用
bigendianstruct.\uuu init\uuu()
。很好,但如果我修复了代码,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)中创建子类,我不会得到警告。但是,如果我从C模块中的
smbus.smbus
创建子类,我也不会得到警告


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

尝试使用新型的
super
调用:

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

啊,那应该是显而易见的尝试。谢谢它修复了警告。不过我很好奇,Structure/bigendianstucture是否使用super()?我看到的建议是在超类使用super()时使用super()。。。