python runtime_error ai_generated true

NotImplementedError

ID: python/notimplementederror

Also available as: JSON · Markdown
90%Fix Rate
90%Confidence
50Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
311 active

Root Cause

Abstract method not implemented in subclass. The parent class requires you to override this method.

generic

Workarounds

  1. 95% success Implement the method in your subclass with the correct signature
    class MySubclass(BaseClass):
        def required_method(self, arg):  # Match parent's signature exactly
            return self.process(arg)

    Sources: https://docs.python.org/3/library/abc.html#abc.abstractmethod

  2. 85% success If you don't need this method, provide a no-op: def method(self): pass
    def method(self): pass

    Sources: https://docs.python.org/3/library/exceptions.html#NotImplementedError

Dead Ends

Common approaches that don't work:

  1. Call super() to use parent implementation 85% fail

    Parent raises NotImplementedError — there is no implementation to call

  2. Remove the abstract method from parent 70% fail

    Other subclasses may depend on the abstract contract

Error Chain

Preceded by: