슈퍼 클래스 __init__에 대한 파일 린트 오 탐지
문제
내가 수업을 파생한다면 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
순수한 파이썬입니다. 하지만 서브 클래스에서도 경고를받지 못합니다. smbus.SMBus
, C 모듈에 있습니다.
W0231을 비활성화하는 것 외에는 해결 방법을 아는 사람이 있습니까?
해결책
새 스타일을 사용해보십시오 super
전화 :
class Foo(ctypes.BigEndianStructure):
def __init__(self):
super(Foo, self).__init__()
제휴하지 않습니다 StackOverflow