Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

To me, this looks like a way too extensive edit jsut to emphasize a corner case 
that rarely arises in practice.   It bends over backwards to force an awkward 
definition regarding what an ABC really is.

A more minimal edit is to just note that inspect.isabstract() returns true if a 
class inherits from ABC and has at least one remaining abstractmethod.  

That tells the truth without having to redefine an ABC.  And it matches the 
spirit of the ABC mechanism.  At no point does ABCMeta ever require that any 
class in the chain must have ever defined an abstractmethod.  Instead, its only 
rule is that if there is least one remaining abstractmethod, it will refuse to 
instantiate.  Roughly:

  if any(getattr(meth, '__isabstractmethod__', False) for meth in meths):
     raise TypeError("Can't instantiate")
  instantiate(cls)

Note, any() defaults to False if there are no inputs and that the actual C code 
works the same way.  Even if a class never defines any abstractmethods, this 
test still occurs.  For an empty ABC, it just happens to always succeed in 
instantiating because there is no work left to be done.

Worldviews aside, I don't think it helpful to users to everywhere rewrite what 
it means to be an ABC just to make it match the output of inspect.isabstract() 
which is just short for inspect.has_abstract_methods_remaining().

Guido, any thoughts?

----------
nosy: +gvanrossum, rhettinger

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46814>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to