AbstractMethods and NotImplementedError - Python Help - Discussions on Python.org
AbstractMethods and NotImplementedError Python Help steven.daprano (Steven D'Aprano) December 22, 2022, 9:45am 1 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? cameron (Cameron Simpson) December 22, 2022, 8:24pm 2 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. Cheers, Cameron Simpson cs@cskk.id.au