AbstractMethods and NotImplementedError

Are there any experts on the use of ABCs and abstractmethod who could weigh in on a documentation issue please?

The documentation for the exception says that abstract methods should raise NotImplementedError. Obviously this is not mandatory. Abstract methods can have default implementations. But for those that don’t, the docs currently suggest raising.

Should we remove that recommendation? Or should we also mention that recommendation to the docs for abstractmethod itself?

1 Like

My opinion: You don't need to raise NotImplementedError for abstract methods · Issue #100400 · python/cpython · GitHub

An “abstract class” is normally made with ABC and abstractmethod in
modern Python. But the generic notion of an abstract class does not
require these, and without them NotImplementedError is a sensible way
to express that a method still needs implementation.

I’ve said this more verbosely in the issue.

Cameron Simpson cs@cskk.id.au