Abstract Classes¶
pcapkit.utilities.inspect holds isabstract(), which tells an abstract
class from a concrete one without the interpreter’s abstract flag, so the answer is the
same on every interpreter, during __init_subclass__() and after the class
is made (#2784). Protocol.__init_subclass__ decides with it whether a
class names itself in the by-name registry. It behaves the same everywhere rather
than gating on a version, so it is not in compat; see
Choosing Between utilities and corekit.
Added in version 1.6.0.
- pcapkit.utilities.inspect.isabstract(cls)[source]¶
Whether
clsis an abstract class, without its__flags__.A class made by
abc.ABCMetais abstract when its own namespace holds an abstract method, or when a name one of its bases lists in__abstractmethods__still resolves to an abstract method on it. That is howabc.ABCMetacomputes__abstractmethods__, so the answer agrees with it after the class is made, and is already the same while__init_subclass__()runs, beforeabc.ABCMetahas set it.inspect.isabstract()takes the same route there, but reads the interpreter’s abstract flag first.- Parameters:
cls (
Any) – Object to check. Anything other than a class made byabc.ABCMetais not abstract.- Return type:
- Returns:
Whether
clsis abstract.