Can __abstractmethods__ be made documented/public?

ABCs define an __abstractmethods__ frozenset which is computed at class definition time and lists the methods which are abstract.

It’s not in the docs but I recently had cause[1] to go spelunking in a class __new__ to look at this data. You can compute it yourself and the docs contain __abstractmethod__ as an attribute of decorated methods. But it’s already being built for you by ABCMeta, so why not use that instead of recomputing?

I don’t think the implementation has changed significantly in years. Would there be anything wrong with documenting this set, and committing to it as part of the contract around ABCs?


  1. an abstract class which inherits from dict, not sure if it’s a good idea but maybe a little besides the point ↩︎

1 Like