سؤال

إذا كنت اشتقاق فئة من 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. أنا لا أحصل على التحذير إذا I فئة فرعية من أحد صفوفي، أو القول، SocketServer.BaseServer وهو الثعبان النقي. لكنني أيضا لا تحصل على التحذير إذا I فئة فرعية من smbus.SMBus، والتي هي في وحدة نمطية C.

أحد يعرف من حلا آخر غير تعطيل W0231؟

هل كانت مفيدة؟

المحلول

وحاول استخدام المكالمات super جديد على غرار:

class Foo(ctypes.BigEndianStructure):
    def __init__(self):
        super(Foo, self).__init__()
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top